This function attribute informs the compiler that a static function is to be retained in the object file, even if it is unreferenced.
Functions marked with __attribute__((used))
are tagged in the object file to avoid removal by linker unused section removal.
Note:
Static variables can also be marked as used, by using __attribute__((used)).
Example
static int lose_this(int);
static int keep_this(int) __attribute__((used)); // retained in object file
static int keep_this (int arg) {
return (arg+1);
}
static int keep_this_too(int) __attribute__((used)); // retained in object file
static int keep_this_too (int arg) {
return (arg-1);
}
int main (void) {
for (;;);
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.