GCC warnings for unused global variables

Nathan Sidwell nathan@codesourcery.com
Thu May 1 17:21:00 GMT 2003


Kean Johnston wrote:

>>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".
then is should be volatile
	static const volatile rcsid[] = "my file";

not that this helps dusty decks ...

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org




More information about the Gcc mailing list