04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

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.

Compiler-specific Features<br />

Example<br />

void Variable_Attributes_unused_0()<br />

{<br />

static int aStatic =0;<br />

int aUnused __attribute__ ((unused));<br />

int bUnused;<br />

aStatic++;<br />

}<br />

In this example, the compiler warns that bUnused is declared but never referenced, but<br />

does not warn about aUnused.<br />

Note<br />

The GNU compiler does not give any warning.<br />

4.5.10 __attribute__((used))<br />

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

object file, even if it is unreferenced.<br />

Static variables marked as used are emitted to a single section, in the order they are<br />

declared. You can specify the section that variables are placed in 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 />

Static functions can also be marked as used using __attribute__((used)).<br />

Usage<br />

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

Example<br />

static int lose_this = 1;<br />

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

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

4-54 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

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

Saved successfully!

Ooh no, something went wrong!