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.

C and C++ Implementation Details<br />

5.2.8 Extern inline functions<br />

The ISO C++ Standard requires inline functions to be defined wherever you use them.<br />

To prevent the clashing of multiple out-of-line copies of inline functions, the C++<br />

compiler emits out-of-line extern functions in common sections.<br />

Out-of-line inline functions<br />

The compiler emits inline functions out-of-line, in the following cases:<br />

• The address of the function is taken, for example:<br />

inline int g()<br />

{<br />

return 1;<br />

}<br />

int (*fp)() = &g;<br />

• The function cannot be inlined, for example, a recursive function:<br />

inline unsigned int fact(unsigned int n) {<br />

return n < 2 1 : n * fact(n - 1);<br />

}<br />

• The heuristic used by the compiler decides that it is better not to inline the<br />

function. This heuristic is influenced by -Ospace and -Otime. If you use -Otime, the<br />

compiler inlines more functions. You can override this heuristic by declaring a<br />

function with __forceinline. For example:<br />

__forceinline int g()<br />

{<br />

return 1;<br />

}<br />

See also --forceinline on page 2-58 for more information.<br />

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

ID101213<br />

Non-Confidential,

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

Saved successfully!

Ooh no, something went wrong!