Re: How to use __attribute__((used))?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 17 Sep 2013 10:54:30 -0400
Paul Smith <paul@xxxxxxxxxxxxxxxxx> 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'.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux