cpp bug

Neil Booth neil@daikokuya.demon.co.uk
Thu May 23 05:02:00 GMT 2002


Bob Kenny wrote:-

> I have just upgraded from 2.95.2 to 3.0.1 and when compiling programs I
> get a warning from the pre-processor saying
> 
> extra tokens at end of xxxxxx directive
> 
> This is caused by commands such as
> 
> #endif FRED
> 
> On looking at the code in cpplib.c in the routine ckeck_eol, the warning
> is generated by cpp_pedwarn wich is a pedantic warning but there is no
> test for the pedantic flag being set. I have overcome this by using 
> 
>   if (CPP_PEDANTIC (pfile) && token.type != CPP_EOF)
> 
> so that the warning is only issued if the pedantic flag is used.
> 
> Is this a bug or is it now a non-pedantic warning. In Solaris some of
> their own .h files generate this warning so it is a bit annoying.

The code is correct.  Warnings are flagged pedantic to ensure
they become errors with -pedantic-errors; in all other respects it's
the same as a normal warning.

There is no way to turn off the warning; either compile with a local
change like you did, or use 3.2 CVS which accepts -Wno-endif-labels
to turn off this warning for #else and #endif.

Neil.



More information about the Gcc-bugs mailing list