[cfarm-users] Two problems on the gcc119 machine

Kaz Kylheku kaz at kylheku.com
Tue Sep 20 22:43:39 CEST 2022


On 2022-09-18 07:14, Bruno Haible via cfarm-users wrote:
> On the gcc119 (AIX 7.2) machine, there are two problems:

Should I be porting anythnig to AIX? Does anyone use it any more?

Simple code like this doesn't compile:

  #include <netinet/in.h>

  // ...

  void foo(struct in6_addr *addr)
  {
    return bar(addr->s6_addr, 16);
  }

gcc complains: error: 'union <anonymous>' has no member named 's6_addr'; did you mean 's6_addr8'?

Getting stuff working on this platform seems like make-work, for the benefit of approximately
zero users.

Look what they have in the header:

#ifndef _IN6_ADDR_STRUCT
struct in6_addr {
        union {
                uint32_t s6_addr32[4];
#ifdef notyet
                uint64_t s6_addr64[2];
#endif /* notyet */
                uint16_t s6_addr16[8];
                uint8_t  s6_addr8[16];
        } s6_addr;
};
#define s6_addr32       s6_addr.s6_addr32
#ifdef notyet
#define s6_addr64       s6_addr.s6_addr64
#endif /* notyet */
#define s6_addr16       s6_addr.s6_addr16
#define s6_addr8        s6_addr.s6_addr8        // macro B
#define s6_addr         s6_addr.s6_addr8        // macro A
#define INET6_ADDRSTRLEN        46
#define _IN6_ADDR_STRUCT
#endif /* _IN6_ADDR_STRUCT */

Given  foo->s6_addr,  we get this expansion

   foo->s6_addr.s6_addr8   // via macro A

   foo->s6_addr.s6_addr.s8_addr // via macro B

They have a bunch of the same identifiers unhygienically
both sides of the macro definitions, and also called the internal
union s6_addr, instead of taking advantage of the implementation
reserved namespace:

ifndef _IN6_ADDR_STRUCT
struct in6_addr {
        union {
                /* ... */
                uint8_t  __s6_addr8[16];
        } __s6_addr_u;
};
#define s6_addr8        __s6_addr_u.__s6_addr8  // actually, don't even expose this!!!
#define s6_addr         __s6_addr_u.__s6_addr8
#define _IN6_ADDR_STRUCT
#endif /* _IN6_ADDR_STRUCT */



More information about the cfarm-users mailing list