Re: what's this syntax?

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

 



"Michael Gong" <mwgong@xxxxxxxxxxxxxx> writes:

> My question is how to interperate the code, since I don't understand
> its syntax.
> 
> If it is a C99 code, what's the C99 feature for it ?

I'm sorry, I don't understand this question.  What kind of answer are
you looking for?

> >> 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.

> >>            )
> >>         ) == 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