problem initializing a structure to zero

Jelle Geerts bughunter2@googlemail.com
Fri Apr 11 15:51:00 GMT 2008


Hello,

When compiling the enclosed source code (see attachment), I get the
following warnings from GCC:
--------
test.c: In function `main':
test.c:15: warning: missing initializer
test.c:15: warning: (near initialization for `my_struct.var1')
--------

When trying the suggestion (something I read on
http://bytes.com/forum/thread212987.html) of adding braces around
`{0}' to make it `{{0}}', GCC gives me the following warnings:
--------
test.c: In function `main':
test.c:15: warning: braces around scalar initializer
test.c:15: warning: (near initialization for `my_struct.var0')
test.c:15: warning: missing initializer
test.c:15: warning: (near initialization for `my_struct.var1')
--------

What is the correct way to easily initialize a struct and all it's
members (recursively perhaps?) to zero?

I read that `= {0}' is valid code and shouldn't need to be changed.
I'm unsure whether this is true.

Thanks in advance,
Jelle Geerts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: application/octet-stream
Size: 367 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20080411/7ae1fcd0/attachment.obj>


More information about the Gcc-help mailing list