Re: OT: Seed7 on OS X - WAS: Re: Seeking computer-programming job (Sunnyvale, CA)

[trimmed language-specific groups, who probably don't care about
my opinions on writing C; possibly comp.programming doesn't care
either, but I need to keep *some* group]

Richard Heathfield <rjh@xxxxxxxxxxxxxxx> writes:

Please explain the potential for harm in:

struct tm foo = {0};

that causes this message:

foo.c:6: warning: missing initializer
foo.c:6: warning: (near initialization for `foo.tm_min')

and which vanishes when the code is changed to:

struct tm foo = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

struct tm is special, because it is defined by the standard C
library, not by the ordinary user of a C implementation, and
because the order and number of its members varies from one
implementation to another. The GNU C library implementation, for
example, adds two members that are not mentioned in the C
standard. That means that there is no way to specify a portable
initializer it without provoking a warning one way or another on
the GCC version above.

C and POSIX have a lot of structures in the same situation.

For structures that I define in my own code, I prefer to provide
a macro that specifies a full initializer, e.g.:

struct whoozit {
int quux;
const char *pow;
long int whazzle;
#define WHOOZIT_INITIALIZER {0, "yowza!", 1L}

That sidesteps the whole issue.
I love deadlines.
I love the whooshing noise they make as they go by.
--Douglas Adams