* forcing a static char string into libs and executables
@ 2005-01-02 14:40 Bruce Allen
0 siblings, 0 replies; only message in thread
From: Bruce Allen @ 2005-01-02 14:40 UTC (permalink / raw)
To: gcc-help; +Cc: Bruce Allen
I've searched the standard places, manuals and mailing lists and not found
the answer to this.
I use the 'ident' utility to parse CVS strings from libs and executables.
It's a convenient tool for tracking version information: Typical output
looks like this (get file is an executable):
ident get_file
get_file:
$Id: get_file.C,v 1.4 2004/12/08 00:39:22 ballen Exp $
The string are embedded typically with a declaration like this:
static volatile const char __attribute__((unused))
*BOINCrcsid= $Id: get_file.C,v 1.4 2004/12/08 00:39:22 ballen Exp $";
The 'volatile' is a (perhaps misguided) attempt to force the
compiler-assembler-linker chain to preserve this quantity even under
agressive optimization. The __attribute((unused)) is to avoid compiler
warnings about BOINCrcsid, which is used nowhere in the code.
This worked with gcc 3.2.2 and earlier but fails with gcc 3.4.2. With gcc
3.4.3, I get:
ident get_file
get_file:
ident warning: no id keywords in get_file
If I change to __attribute__((used)) then my const char string comes back
and ident works correctly. So:
(1) Is there a better way? which will work with older and newer gcc
versions?
(2) At which gcc version did __attribute__((used)) start being supported?
I can't find it documented. If someone can point me to the file or
directory in gcc CVS I'll happily track this down.
I don't subscribe to this list: replies copied to ballen@uwm.edu would be
greatly appreciated.
Cheers,
Bruce
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-01-02 14:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-02 14:40 forcing a static char string into libs and executables Bruce Allen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).