Re: How to explain this syntax?

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

 



On Wed, 2023-04-19 at 13:40 +0200, Andy via Gcc-help wrote:
> I meet odd struct + colon syntax:
> in gcc/gcc/testsuite/gcc.c-torture/compile/init-3.c
> is
> 
> struct something X = {
>  foo: { },
>  bar: 1,
> };
> bar:1 is one bit field? what means foo? is the same as
> struct empty foo; where struct empty { };
> colon is not only reserved to bitfields?

It's an obsoleted GNU extension:

https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

> 
> Second (init-2.c):
> initializer
> 
> struct
> {
>   int e1, e2;
> } v = { e2: 0 };
> why not e2=0, colon instead of assign operator?

The point of the test case is ensuring GCC backward compatible with the
old extension, though it's obsoleted.

The GCC test cases are test cases, not some "material to learn C".

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[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