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 />

Although related, this function attribute is not equivalent to the __pure keyword. The<br />

function attribute equivalent to __pure is __attribute__((const)).<br />

Example<br />

int Function_Attributes_pure_0(int b) __attribute__ ((pure));<br />

int Function_Attributes_pure_0(int b)<br />

{<br />

static int aStatic;<br />

aStatic++;<br />

return b++;<br />

}<br />

int Function_Attributes_pure_2(int b)<br />

{<br />

int aLocal=0;<br />

aLocal += Function_Attributes_pure_0(b);<br />

return 0;<br />

}<br />

The call to Function_Attributes_pure_0 in this example might be eliminated because its<br />

result is not used.<br />

4.3.9 __attribute__((section))<br />

The section function attribute enables you to place code in different sections of the<br />

image.<br />

Note<br />

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

compiler.<br />

Example<br />

In the following example, Function_Attributes_section_0 is placed into the RO section<br />

new_section rather than .text.<br />

void Function_Attributes_section_0 (void)<br />

__attribute__ ((section ("new_section")));<br />

void Function_Attributes_section_0 (void)<br />

{<br />

static int aStatic =0;<br />

aStatic++;<br />

}<br />

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

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!