This variable attribute informs the compiler that a static
variable is to be retained in the object file, even if it is unreferenced.
Static variables marked as used are emitted to a single section,
in the order they are declared. You can specify the section that
variables are placed in using __attribute__((section("name"))).
Data marked with __attribute__((used)) is
tagged in the object file to avoid removal by linker unused section
removal.
Note
This variable attribute is a GNU compiler extension that the
ARM compiler supports.
Note
Static functions can also be marked as used using __attribute__((used)).
Usage
You can use __attribute__((used)) to build
tables in the object.
Example
static int lose_this = 1;
static int keep_this __attribute__((used)) = 2; // retained in object file
static int keep_this_too __attribute__((used)) = 3; // retained in object file
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.