Good reasons why mingling declarations and statements is gnu89?
Joseph S. Myers
jsm28@cam.ac.uk
Tue Feb 4 20:50:00 GMT 2003
On Tue, 4 Feb 2003, Bonzini wrote:
> Is any reason why this C99 feature
>
> int a = 2;
> printf ("%d", a);
> int b = 3;
> printf ("%d", b);
>
> is enabled by gnu89? Or is it creeping featurism only?
Extensions are enabled whenever consistent with the standard version
selected. This means that this feature is also accepted in c89 mode, only
rejected with -pedantic. That policy was decided long ago, probably when
RMS was maintaining GCC. If you want code not in the standard to be
rejected, use -pedantic (or eventually -Wc89, to get such warnings still
when gnu99 is default). Attempting to maintain a -W2.95 option (warn for
code that might not be supported or might behave differently with 2.95)
wouldn't be a good idea; if you want to know whether code with work with a
particular past version, test with that version rather than having GCC
know what did or didn't work in every version. Just treat 2.95 as a
limited old compiler that doesn't support the current C standard in any
useful way, which you have to limit your code for just as you have to
limit it if you want K&R compilers to compiler your code (and note that
K&R-incompatible code often creeps into GCC despite -Wtraditional).
> typeof, &&, and even nested functions all fit this purpose). Secondly, this
> falls in the same category for which -Wall enables warnings -- dubious,
> easily fixable constructs.
It's not at all a dubious construct. It's a useful feature of the C
standard and of C++.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc
mailing list