You copied the Doc URL to your clipboard.

Arm Compiler armclang Reference Guide : __attribute__((used)) variable attribute

__attribute__((used)) variable attribute

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

Data marked with __attribute__((used)) is tagged in the object file to avoid removal by linker unused section removal.

Note

Static functions can also be marked as used, by using __attribute__((used)).

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
Was this page helpful? Yes No