This is the mail archive of the
mailing list for the GCC project.
RE: PATCH (head): -Wunused-static-variable
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Kean Johnston <jkj at sco dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 May 2003 14:59:26 +0100 (BST)
- Subject: RE: PATCH (head): -Wunused-static-variable
- References: <008501c310b0$4a06bd30$03419384@shrike>
On Fri, 2 May 2003, Kean Johnston wrote:
> #ifndef LINT
> static char *sccsid = "@(#)blahblah";
> 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