Should warnings be issued for unrecognised pragmas ?
Donald Koch
koch@cognex.com
Fri Oct 17 14:36:00 GMT 1997
> I am currently writting a patch for gcc2 that implements a new command
> line option '-wunrecognised-pragmas' which will cause warning messages
> to be generated when GCC encounters pragmas which is does not handle.
> At the moment this patch also enables these warnings if -Wall is
> enabled, expect for the case where the pragmas are in system header
> files. Is this the right thing to do ?
If you mean by "this", enabling it with -Wall, no.
Consider the use of "-Werror -Wall", where the desired effect is to
make sure there are no iffy constructs in the code; would failure
to compile because there was an unrecognized pragma which is needed
for some other compiler/platform be desirable? -Wall check for too
many useful things, which is what it should do.
> The '89 ANSI C standard says:
> "Any pragma that is not recognized by the implementation is ignored."
>
> It is my opinion that "ignoring" is not the same as "not issuing a
> warning", if such warnings have been requested, and that it is
> important to know if a compiler is ignoring pragmas as they may have
> been intended to affect code generation.
>
> Any comments ?
>
> Nick Clifton
Otherwise, I think the '-wunrecognised-pragmas' could be very useful;
e.g., for the case where you only have one platform/compiler and an
unrecognized pragma indicates a typo.
-d
More information about the Gcc
mailing list