For about as long as RCS has been around, like 20 years, I have been
putting ID strings into C program source files using a statement such
as:

static char *rcsid="$Id:$";

The RCS program ci(1) fills in the $Id:$ template with the current
version and date of the program.  The character string is compiled
into the object file and shows up in the linked runnable program. and
can be displayed with the command ident(1).  You all know this
already.

Starting recently, GCC seems to optimize this string away if it is not
referred to anywhere in the program.  This happens with gcc 4.2.1, as
I discovered this morning.   A previous version, gcc 3.4.4, does not
do this.

The obvious sloppy workaround is to make the program slightly more
verbose by actually using rcsid.
fprintf (stderr, "%s\n", rcsid);

Less obvious, where foo is some other char* that has been defined
already, and can be temporarily clobbered:
foo = rcsid;

Anyone have a better idea?

    carl
-- 
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to