This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warnings about rcs_id strings: let's settle this
Joe Buck writes:
> As for my answers:
>
> only for const variables? NO. Many old codes do not declare the rcsid
> const, and the fact that we have the flag that will warn about all unused
> static variables means that users can still find them all.
Er, warning about this for non-const static strings is existing practice
with gcc:
#include <stdio.h>
static char unused1[] = "String 1";
static char * unused2 = "String 2";
static char const * unused3 = "String 3";
static char const unused4[] = "String 4";
static char * const unused5 = "String 5";
static const char * const unused6 = "String 6";
int main()
{
printf("Hello, world!\n");
return 0;
}
$ gcc -Wall -g -O2 unused-1.c
unused-1.c:3: warning: `unused1' defined but not used
unused-1.c:4: warning: `unused2' defined but not used
unused-1.c:5: warning: `unused3' defined but not used
$ gcc -v
Reading specs from /usr/local/gnu/bin/../lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs
Configured with: /src/unpack/gnu/gcc-3.2.1/configure --prefix=/opt/CUCSgnu --with-gnu-as --with-as=/opt/CUCSgnu/bin/as --with-gnu-ld --with-ld=/opt/CUCSgnu/bin/ld --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.2.1
$ gcc-2.95.2 -Wall -g -O2 unused-1.c
unused-1.c:3: warning: `unused1' defined but not used
unused-1.c:4: warning: `unused2' defined but not used
unused-1.c:5: warning: `unused3' defined but not used
$ gcc-2.95.2 -v
Reading specs from /usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
--
Jonathan Lennox
lennox@cs.columbia.edu