Selectiv on/off-turning of warnings
Enrico Scholz
Enrico.Scholz@informatik.tu-chemnitz.de
Wed Mar 22 18:27:00 GMT 2000
"Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> writes:
> [...]
> > This happens not only with "-Weffc++", "-ansi -pedantic" produces
> > e.g.:
> > /usr/include/g++-3/std/straits.h:86: warning: ANSI C++ forbids variable-size array `a'
>
> Well, that's clearly a bug in straits.h. The correct action would be
> to fix that, instead of providing more options to the compiler.
AFAIK variable-sized arrays are an extension of gcc. I have tried to put
"__extension__" in front of "char_type a[n];", but the warning remains.
> The compiler does not produce certain warnings for system header
> files.
Limiting this behavior to system-headers only is not a solution. Often
there are third-party libraries which are using non-standard features in
a right manner also (that means ./configure or something else tested
their existence and correct behavior). An example is pointer-arithmetic.
Often I just want to develope _my_ sources _now_ and have not the time
or know-how to modify the 3rd-party interface in a way that the warnings
do not occur anymore or to wait for such a modification.
Grepping the gcc-output seems to be the only way to reach that, but I
don't like it because another layer will be introduced which needs
maintenance and disables some features (e.g. recursive-building of
automake).
> > A reasonable solution could be something like:
>
> I think there would be a long debate whether it is reasonable. For
> one thing, some people claim that #pragma is not reasonable.
Well, #pragma was just a incidence I had. Usage of a language-extension
like __gcc_warnings_enable__ is possible also. I am not sure if the
_Pragma() operator mentioned in other threads is reasonable, because
only C99 knows it but not C++.
I would wonder if such minor technical details can influence the decision
about importing such an option...
> Since the standard says a compiler can do anything it wants when it
> sees a #pragma, I believe some version of gcc used to invoke Emacs
> when it saw a #pragma :-)
I know, but I think these gcc versions misuse^H^H^Hinterpreted the
standard. The standard says (a little bit laxly) that any #pragma that
is not recognized will be ignored.
Supporter of the Emacs-version will say, gcc knows _all_ #pragma's; but
because the case of unrecognized #pragma's is mentioned explicitly I
assume that their amount can not be empty. :)
Enrico
More information about the Gcc
mailing list