Node and Host Name Sizes on HP-UX: Using the Expanded Capabilities of HP-UX

37
In this case, the last two options will require explicit version attributes.
Explicit Version Attributes
Because interfaces that re-export constants do not inherit a version identifier, it is important to add one
explicitly. The version attribute macro defined in sys/stdsyms.h can be used for this purpose.
For example:
#include <sys/stdsyms.h>
#if _INCLUDE_HPUX_API_LEVEL >= 20040821
# if MAXHOSTNAMELEN != 256
error MAXHOSTNAMELEN and API level mismatch /* sanity check */
# endif
#define UVW_ATTR _HPUX_API_VERS_20040821_ATTR /* version attribute */
#else
#define UVW_ATTR /* no version attribute */
# if MAXHOSTNAMELEN != 64
error MAXHOSTNAMELEN and API level mismatch /* sanity check */
# endif
#endif
struct UVW_ATTR uvw {
int uvw_field1;
char uvw_host[MAXHOSTNAMELEN];
}
extern int get_uvw(struct uvw *) UVW_ATTR;
Note that the function get_uvw(), because it has a versioned type as a parameter, automatically
inherits the version identifier from struct uvw. An explicit attribute is not required but is added for
clarity.
The sanity checks provide some compile-time checking that the declarations have been laid out
consistently with the OS headers.
Constants: Providing Multiple Versions
The manner in which multiple versions are provided depends on the design of the code that provides
the get_uvw() interface. Either a parallel implementation approach or a thin converter might be
practical. See “Providing Multiple Versions in a Library”.
With re-export of constants, it might be necessary to add explicit version attributes in the supporting
code.