Subject: Re: Compiler warning levels and sccsid/rcsid
To: None <apm@vipunen.hut.fi>
From: nv90-mho <nv90-mho@nada.kth.se>
List: current-users
Date: 07/25/1995 22:38:21
In message <9507241147.AA24662@kikka.hut.fi>, Antti Miettinen writes:
>>I just did a sup and thought I'd try -Wall when compiling. A lot of the
>>NetBSD code has things like...
>>
>>#ifndef lint
>>static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94";
>>#endif /* not lint */
>>
>>With -Wall this causes a warning...
>>
>>warning: `sccsid' defined but not used
>
>These warnings can be worked around with something like the following:
>
>static char id[] = "$Id$";
>static struct iduse { char *a; struct iduse *b; } iduse = { id, &iduse };
>
>Ugly, yeah. And some day gcc may be clever enough to warn about the
>above too. I suppose it would be hard if not impossible to come up
>with a portable asm() definition for the id strings..
If you have established you have gcc, you might as well use #ident, so
you don't have to "fool" the compiler at all...
>
>But all of this could be put to a header defining a macro. Something
>like the following:
>
>#ifndef lint
># ifdef __GNUC__
># define ID(s) \
- static char id[] = s; \
- static struct iduse { char *a; struct iduse *b; } iduse = { id, &iduse };
+ #ident s
># else
># define ID(s) \
>static char id[] = s;
># endif /* ?__GNUC__ */
>#else
># define ID(s)
>#endif /* ?lint */
>
>And files defining id strings would say `ID("$Id$")'.
- MH