Pelles C forum

Pelles C => Feature requests => Topic started by: Gerome on September 17, 2006, 07:11:47 pm

Title: Anonymous structures + unions wanted :)
Post by: Gerome on September 17, 2006, 07:11:47 pm
Hello Pelle!

It'd be nice to have anonymous structures + unions supported into PellesC :)

Code: [Select]

include <stdio.h>

typedef struct t_test {
   int a;
   union {
      int b;
      struct {
         int c;
         int d;
      };
      struct {
         int e;
         int f;
      };
      int g;
   };
} T_TEST;


int main(void)
{
T_TEST t;
   t.a = 1;
   t.b = 2;
   t.c = 3;
   t.d = 4;
   t.e = 5;
   t.f = 6;
   t.g = 7;
   printf("%d %d %d %d %d %d %d sz %d\n", t.a, t.b, t.c, t.d, t.e, t.f, t.g,
sizeof(t));
getchar();
}


Should give :
1 7 7 6 7 6 7 sz 12

Thanks
Title: Anonymous structures + unions wanted :)
Post by: Mikehg on September 17, 2006, 08:55:35 pm
PellesC already supports this, at least my copy does :)

Mike H.
Title: Anonymous structures + unions wanted :)
Post by: Pelle on September 17, 2006, 10:41:52 pm
Yes - the snippet is non-standard in every way, but if you enable Microsoft extension (the /Ze compiler option) you should get what you want...
Title: Anonymous structures + unions wanted :)
Post by: Gerome on September 18, 2006, 12:50:57 am
Hi,
Quote from: "Pelle"
Yes - the snippet is non-standard in every way, but if you enable Microsoft extension (the /Ze compiler option) you should get what you want...


Thanks Pelle!
Non standard does not always means bad :)
I love unnamed structs & unions :)