29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Compiler</strong>-specific Features<br />

4.5.9 __attribute__((used))<br />

This variable attribute informs the compiler that a variable is to be retained in the object,<br />

even if it is unreferenced.<br />

Variables marked as used are emitted to a single section, in the order they are declared.<br />

You can specify the section into which variables are placed using<br />

__attribute__((section)).<br />

Note<br />

This variable attribute is a GNU compiler extension that is supported by the <strong>ARM</strong><br />

compiler.<br />

Note<br />

Functions might also be marked as used using the corresponding function attribute<br />

__attribute__((used)).<br />

Usage<br />

You can use __attributte__((used)) to build tables in the object.<br />

Example<br />

static int lose_this = 1;<br />

static int keep_this = 2 __attribute__((used)); // retained in object file<br />

static int keep_this_too = 3 __attribute__((used)); // retained in object file<br />

See also<br />

• __attribute__((section)) on page 4-44<br />

• __attribute__((used)) on page 4-35.<br />

4.5.10 __attribute__((weak))<br />

The declaration of a weak variable is permitted, and acts in a similar way to __weak.<br />

• in GNU mode:<br />

extern int Variable_Attributes_weak_1 __attribute__((weak));<br />

• the equivalent in non-GNU mode is:<br />

__weak int Variable_Attributes_weak_compare;<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 4-47<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!