Feature-request: Possibility of transparent unions in structs

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sat Mar 25 01:08:00 GMT 2000


> Can anyone tell me if this feature exists currently in GCC (as a C
> extension), or if possible, can be added to gcc 2.96 / 3.0?

Thanks for your bug report. Please note that, in C++, you can write

struct foo {
  int type;
  union {
    int id;
    int *data;
    char *string;
  };
};

and then access the union fields transparently. I've added a
change-request to GNATS. Please also have a look at

http://gcc.gnu.org/cgi-bin/fom.cgi?file=12

Regards,
Martin



More information about the Gcc-bugs mailing list