How to use __attribute__((used))?
ketmar
ketmar@ketmar.no-ip.org
Tue Sep 17 15:07:00 GMT 2013
On Tue, 17 Sep 2013 10:54:30 -0400
Paul Smith <paul@mad-scientist.net> wrote:
> Here's my sample. I've tried moving the attribute around but no joy:
it's not working this way. 'used' intended to keep *global* static
variables. for example:
---
#include <stdlib.h>
static __attribute__((used)) const char *myid = "THIS IS MY UNIQUE IDENTIFIER!";
int main () {
return 0;
}
---
without '__attribute__((used))' myid will be optimized out (with
warning). but with 'used' gcc will include it in object file (and
linked executable).
but this will not 'keep the variable and it's meaningless value away
from optimizer'.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20130917/d32d21a0/attachment-0001.sig>
More information about the Gcc-help
mailing list