This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

unused variable warning


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>

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]