我有一段代码,它获取本地 IPv6 地址。带有 std=c99 的 gcc 和 clang 在这些行上崩溃:
ipv6addr.s6_addr16[i] = htons((unsigned short int)tmp);
if (!(IN6_IS_ADDR_LOOPBACK(ipv6addr.s6_addr32)
|| IN6_IS_ADDR_UNSPECIFIED(ipv6addr.s6_addr32)
|| IN6_IS_ADDR_LINKLOCAL(ipv6addr.s6_addr32))){
ipv6.c:43:13: error: no member named 's6_addr16' in 'struct in6_addr'
ipv6addr.s6_addr16[i] = htons((unsigned short int)tmp);
~~~~~~~~ ^
ipv6.c:45:39: error: no member named 's6_addr32' in 'struct in6_addr'
if (!(IN6_IS_ADDR_LOOPBACK(ipv6addr.s6_addr32)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
等等
使用标准选项编译会成功。这是为什么?完整源代码可在http://pastebin.com/hQ3VBSKe获得