Subject: Re: Compiler warning levels and sccsid/rcsid
To: None <current-users@NetBSD.ORG>
From: Christos Zoulas <christos@deshaw.com>
List: current-users
Date: 07/24/1995 20:19:12
In article <9507241147.AA24662@kikka.hut.fi> apm@vipunen.hut.fi 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..
>
>But all of this could be put to a header defining a macro. Something
>like the following:
>

The best I've seen is:

# ifndef __GNUC__
#  define RCSID(id) static const char *rcsid = (id);
# else
#  define RCSID(id) static const char *rcsid() { return id ? id : rcsid(); }
# endif /* !__GNUC__ */

christos