In article <11**********************@p77g2000hsh.googlegroups .com>,
Nick Keighley <ni******************@hotmail.comwrote:
>Hi,
is this correct:-
typedef struct
{
long frequency;
} Structure;
Structure my_struct [32] = {0};
specifically the initialisation of the struct. I get warnings about
missing braces. Should there be two sets of braces?
This initialization is correct and sensible, and warnings about use of
"{0}" as an initializer for aggregate types should be ignored.
If you were attempting to initialize with nonzero values, you'd want to
use more braces for clarity and resistance to changes; but a single zero
will explicitly initialize the first member of the first struct in the
array and implicitly zero-initialize the rest, which is exactly what you
want, and the compiler isn't clever enough to recognize the difference
between the all-zero and the not-all-zero cases.
dave
--
Dave Vandervies
dj******@csclub.uwaterloo.ca
I presume the difference is that Laurier's off-campus environment includes the
University of Waterloo, whereas the best we can offer by way of off-campus
environment is, well, Laurier. . . . --Chris Redmond in uw.general