9.49 __attribute__((used)) function attribute

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

This function attribute is a GNU compiler extension that the ARM compiler supports.

Note

Static variables can also be marked as used using __attribute__((used)).

Example

static int lose_this(int);
static int keep_this(int) __attribute__((used));     // retained in object file
static int keep_this_too(int) __attribute__((used)); // retained in object file
Related reference
9.67 __attribute__((used)) variable attribute
9.46 __attribute__((section("name"))) function attribute
Related information
Elimination of unused sections
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.