The task at hand is to initialize a variable of
type "struct in6_addr" in a portable way. For instance:
/* NetBSD - /usr/include/netinet6/in6.h */
struct in6_addr {
union {
__uint8_t __u6_addr8[16];
__uint16_t __u6_addr16[8];
uint32_t __u6_addr32[4];
} __u6_addr; /* 128-bit IP6 address */
};
/* Linux - /usr/include/netinet/in.h */
struct in6_addr
{
union
{
uint8_t u6_addr8[16];
uint16_t u6_addr16[8];
uint32_t u6_addr32[4];
} in6_u;
};
/* Solaris - /usr/include/netinet/in.h */
struct in6_addr {
union {
uint8_t _S6_u8[16]; /* IPv6 address */
uint32_t _S6_u32[4]; /* IPv6 address */
uint32_t __S6_align; /* Align on 32 bit
boundary */
} _S6_un;
};
Is there a way to build a portable static initializer
for struct in6_addr, other than selecting among several
compile-time codes by using precompiler directives?
Or else, would it be safer to use a non-static initialization?
Please advise.