Re: what's this syntax?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Lance Taylor <iant@xxxxxxxxxx> writes:

> > >> void foo() {
> > >>   if(
> > >>       ( __extension__
> > >>           (
> > >>               (
> > >>                   (
> > >>                       union {
> > >>                           int a;
> > >>                           int b;
> > >>                      }
> > >>                   ) { .a =7 }
> 
> This is a constructor expression.  The type is the anonymous union.
> The value is the initializer expression, which in this case sets field
> 'a' to '7'.
> 
> > >>               ) .b
> 
> This is a reference to field 'b' of the newly constructed union.  It
> should be zero or garbage, I can't remember which.

Whoops, sorry, I was thinking struct.  Since it's a union, field 'b'
should also have the value '7'.

> > >>            )
> > >>         ) == 7 ) {
> > >>               printf("abc\n");
> > >>     }else {
> > >>               printf("def\n");
> > >>    }
> > >> }

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux