How do I get the anonymous struct/union behaviour activated by -fplan9-extensions
in GCC to work in Clang?
I'm getting errors assigning to members of anonymous when using designated initializers, and I'm not getting the free casting to the type of an anonymous member. Both these work under GCC with the aforementioned extension activated.
typedef struct {int hi;} Embedded;
typedef struct {Embedded;} Encapsulating;
Encapsulating poo = {.hi = 3;};
error: field designator 'hi' does not refer to any field in type 'Encapsulating'
void takes_embedded(Embedded *m);
takes_embedded(&poo);
warning: incompatible pointer types passing 'Encapsuating *' to parameter of type 'Embedded *'
Here's how to get the -fplan9-extensions
functionality in Clang:
Some of the -fplan9-extensions
functionality (the struct { Embedded; }
part) is already available under the -fms-extensions
argument, but designated initializers for such anonymous members are not supported. The other part is similar in spirit to GCC's __attribute__((transparent_union))
functionality, which Clang already supports.