This is the mail archive of the 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]

RE: PATCH (head): -Wunused-static-variable

On Fri, 2 May 2003, Kean Johnston wrote:

> #ifndef LINT
> static char *sccsid = "@(#)blahblah";
> #endif
> Having this be for const only breaks the intent. There are several
> hundred thousand lines of code in many projects that use this, and
> were using it since before const was even in the language.

There are hundreds of thousands of lines of code that used to use various
forms of implicit int (which were removed in C99).  That doesn't mean we
shouldn't warn for them in -Wall (and in due course warn for them by
default), or that such code shouldn't need to be cleaned up to avoid -Wall
warnings.  Good style for over a decade has been to use const for data
that isn't modified so it gets in a readonly section (shared by multiple
processes) - in this case, good style is static const char sccsid[] rather
than static const char *const sccsid, as the pointer is unnecessary.

Having it for const only clearly fits the documented intent of
-Wunused-variable being for nonconst, and provides a clean and easy way
(not even GCC-dependent) of avoiding the warning; the warning for nonconst
fits the definition of -Wall.

Joseph S. Myers

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