designated inits

todd freed todd.freed@gmail.com
Mon Jul 12 18:43:00 GMT 2010


Referring to section 5.21 of the docs - Designated Initializers

typedef struct
{
   int a;
   int b;
} foo;

Is there a way I can get this effect

foo myfoo = { .a = 0, .b = 0 };

without specifying each field? I just want the whole structure
initialized to zero.

Note: if I just do this

foo myfoo;

then I get 'use of uninitialized value' errors in valgrind.

Thanks,

-Todd



More information about the Gcc-help mailing list