This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
in6_addr and problems accessing members
- From: Jeffrey Walton <noloader at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Fri, 25 Mar 2016 10:12:54 -0400
- Subject: in6_addr and problems accessing members
- Authentication-results: sourceware.org; auth=none
- Reply-to: noloader at gmail dot com
Hi Everyone,
I'm trying to understand what is going on below. I believe I have
glibc's in6.h header. I'm having trouble access members of the of
struct in6_addr:
error: âstruct in6_addrâ has no member named âu6_addr32â
And:
error: âstruct in6_addrâ has no member named âin6_uâ
I've looked at the CONFORMANCE document, but I don't really see where
there might be a discrepancy.
Would anyone be able to help guide me through this?
My apologies for the troubles. Thank you in advance.
----------
$ find /usr/include/ -name 'in6.h'
/usr/include/linux/in6.h
$ cat /usr/include/linux/in6.h
...
#if __UAPI_DEF_IN6_ADDR
struct in6_addr {
union {
__u8 u6_addr8[16];
#if __UAPI_DEF_IN6_ADDR_ALT
__be16 u6_addr16[8];
__be32 u6_addr32[4];
#endif
} in6_u;
#define s6_addr in6_u.u6_addr8
#if __UAPI_DEF_IN6_ADDR_ALT
#define s6_addr16 in6_u.u6_addr16
#define s6_addr32 in6_u.u6_addr32
#endif
};
#endif /* __UAPI_DEF_IN6_ADDR */
...
Next:
$ cat test.cc
#include <stdint.h>
#include <netinet/in.h>
/* gcc -DNDEBUG -g2 -O2 -ansi test.cc -o test.exe */
int main(int argc, char* argv[])
{
struct in6_addr addr1, addr2;
const uint32_t addr3 = addr2.u6_addr32[0];
const uint32_t addr4 = addr2.in6_u.u6_addr32[0];
return 0;
}
Finally:
$ gcc -DNDEBUG -g2 -O2 test.cc -o test.exe
test.cc: In function âint main(int, char**)â:
test.cc:9:34: error: âstruct in6_addrâ has no member named âu6_addr32â
const uint32_t addr3 = addr2.u6_addr32[0];
^
test.cc:10:34: error: âstruct in6_addrâ has no member named âin6_uâ
const uint32_t addr4 = addr2.in6_u.u6_addr32[0];
^
$ gcc -DNDEBUG -g2 -O2 -ansi test.cc -o test.exe
test.cc: In function âint main(int, char**)â:
test.cc:9:34: error: âstruct in6_addrâ has no member named âu6_addr32â
const uint32_t addr3 = addr2.u6_addr32[0];
^
test.cc:10:34: error: âstruct in6_addrâ has no member named âin6_uâ
const uint32_t addr4 = addr2.in6_u.u6_addr32[0];
^
I've also tried manually defining __UAPI_DEF_IN6_ADDR and
__UAPI_DEF_IN6_ADDR_ALT with no joy.