unused variable warning
skaller
skaller@users.sourceforge.net
Mon Aug 29 05:41:00 GMT 2005
In gcc/g++ version 4.0 there is no way to turn off the
unused variable warning enabled by -Wall with a command
line switch.
I think this is a bug: it should be possible to selectively
turn on or off all warnings (on the command line).
The advice in the documentation is to attach
__attribute__((unused))
to the selected variable. This may be inappropriate for
three distinct reasons:
(a) It is a GNU extension
(b) it clutters the code
(c) It isn't always easy to tell if a variable is unused
Comment (c) means: C/C++ code is not always hand written.
In my case I am generating code that sometimes contains
an unused variable as a result of a conservative optimisation failing
to detect the variable is not required.
I can of course just enable all the warnings selected by -Wall,
other than the unused warning .. but this has two problems:
(a) it is gcc version specific which warnings can be produced,
so it would be necessary to generate and consult configuation
data .. this may not be possible in a cross compilation situation
(where a process is preparing script to be executed on another
machine, for example).
(b) it makes a real mess of the build having such long
command lines .. (gcc provides lots of warnings :)
BTW: gcc/g++ 4.0 is one heck of a better compiler than
the 3.x series! Nice work!!
[Pls CC me as I don't subscribe to this list]
--
John Skaller <skaller at users dot sourceforge dot net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20050829/4cd74a4d/attachment.sig>
More information about the Gcc
mailing list