in6_addr and problems accessing members

Jeffrey Walton noloader@gmail.com
Fri Mar 25 14:13:00 GMT 2016


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.



More information about the Libc-help mailing list