From: Bruce Allen <ballen@gravity.phys.uwm.edu>
To: gcc-help@gcc.gnu.org
Cc: Bruce Allen <ballen@gravity.phys.uwm.edu>
Subject: forcing a static char string into libs and executables
Date: Sun, 02 Jan 2005 14:40:00 -0000 [thread overview]
Message-ID: <Pine.GSO.4.21.0501020814520.2673-100000@dirac.phys.uwm.edu> (raw)
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
reply other threads:[~2005-01-02 14:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.21.0501020814520.2673-100000@dirac.phys.uwm.edu \
--to=ballen@gravity.phys.uwm.edu \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).