I use only C99, and, yesterday, I heard that it was impossible to mix several declarations and initializations in ANSI C. Thus, codes like this :
unsigned x = 42, y = 21;
double e = 3.14;
Would be, with gcc’ -pedantic flag :
unsigned x, y;
double e;
x = 42, y = 21;
e = 3.14;
I’m surprised, because I didn’t find any information about that in C89 draft, and a code like this works fine…
unsigned x = 42, y = 21;
double e = 3.14;
Sorry, it seems to be a trivial question, but I did some research, and nothing told me about this rule…
Is it true ?
An initialization is a part of declaration, so you can do initialization in a declaration in both C89/C99:
What you cannot do is to mix statements and declarations in C89: