4.5.9. __attribute__((used))

This variable attribute informs the compiler that a variable is to be retained in the object, even if it is unreferenced.

Variables marked as used are emitted to a single section, in the order they are declared. You can specify the section into which variables are placed using __attribute__((section)).

Note

This variable attribute is a GNU compiler extension that is supported by the ARM compiler.

Note

Functions might also be marked as used using the corresponding function attribute __attribute__((used)).

Usage

You can use __attributte__((used)) to build tables in the object.

Example

static int lose_this = 1;
static int keep_this = 2 __attribute__((used));     // retained in object file
static int keep_this_too = 3 __attribute__((used)); // retained in object file

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential