C99 usage in gcc
Joe Buck
Joe.Buck@synopsys.COM
Mon Feb 2 23:34:00 GMT 2004
On Sat, Jan 31, 2004 at 10:16:59AM -0800, Zack Weinberg wrote:
> Bruce Stephens <bruce@cenderis.demon.co.uk> writes:
>
> >> It is a pedwarn, hence you need -pedantic also.
> >
> > Which is useful, except that it also complains about:
> >
> > #ifdef __cplusplus
> > // foo
> > #endif
>
> As it should. This will be misinterpreted by a plain-C89 compiler;
> comment stripping happens before #ifdef processing.
I disagree. There should be no warning, because the plain-C89 compiler
will *not* misinterpret this file. True, the // will not be interpreted
as a comment; since there is no token "//" in C89 it will be interpreted
as two / tokens. Nevertheless, the token stream with the two / tokens is
ifdef'ed out, so it's a don't care.
Try giving the compiler
#ifdef __cplusplus
/ / foo
#endif
Notice that gcc -pedantic no longer gives a warning.
More information about the Gcc
mailing list