GCC warnings for unused global variables
Kean Johnston
jkj@sco.com
Thu May 1 17:04:00 GMT 2003
> It is not a regression. I said "ignore" because he also said
> "he couldn't modify the source". The REAL way to get rid of
> the warning is to mark the thing __attribute__((unused)).
I agree with Joe. It *IS* a regression. The notion of embedding
object markers (such as rcsid and sccsid do) is a critical one
for large project (like UNIX). It has been around for an AWEFULLY
long time, and I can see little or no value to the warning being
in -Wall. Code can be otherwise perfectly clean, ANSI-compliant
and well engineered, and with this change the warning count, or
error count if -Werror is also used, sky-rocket.
If it was a warning that those developers that WANT it can turn
on, but not be turned on with -Wall, that would be fine, but it
really does break things. IMHO, "break things that previously
worked" == "regression". I have a huge source tree that compiles
cleanly with -Wall -Werror now, and almost the entire tree,
totalling a little over 300 000 files, would break with this warning.
> Or even better, __attribute__((used)). If he fails to do this,
> then at some point GCC will stop emitting that variable to the
> object file entirely, precisely because it isn't used.
THAT would be blatantly wrong. It means the compiler assumes it
knows more about how things may be used than the human who wrote
them does. Just because the source module doesn't use a variable,
*EVEN IF ITS MARKED static* does NOT mean it is unused by other
things, for example, object file analysys tools like "what".
Kean
More information about the Gcc
mailing list