This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Turning warning off
- From: "Kaz Kylheku" <kaz at zeugmasystems dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 31 Aug 2006 14:40:10 -0700
- Subject: RE: Turning warning off
> Michael Young wrote:
> Specifically, I'm looking for a way to turn off a specific
> warning inline, with the ability to restore it again -
That exists only in the form of the __attribute__ ((unused)) mechanism.
You can turn it off for an entire translation unit:
-Wno-unused
Actually you can get a little more fine-grained than that:
-Wno-unused-label
-Wno-unused-variable
-Wno-unusued-parameter
-Wno-unused-value
The -Wno-unused does all of them.
These options are not listed in the manual because ...
Each of these specific warning options also has a negative
for beginning `-Wno-' to turn off warnings; for example,
`-Wno-implicit'. This manual lists only one of the two
forms, whichever is not the default.
> analogous to the #pragma warning directive supported in MS
> VC++ (see
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/vclang/html/_predir_warning.asp for details).
GCC stays away from using #pragma, because of its disadvantages. For
instance, because it's a preprocessor directive, a #pragma cannot be
constructed using macros. Thus to switch among #pragma's based on the
compiler identity, you have to repeat #ifdef everywhere.
#ifdef _MSVC
#pragma warning (disable: NNNN)
#endif
...
#ifdef MSVC
#pragma warning (enable: NNNN)
#endif
The use of the __attribute__ ((unused)) extension can be hidden behind
macros.