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

4.2.4 __declspec(noreturn)<br />

The __declspec(noreturn) attribute asserts that a function never returns.<br />

Note<br />

This attribute has the function equivalent __attribute((noreturn)). However,<br />

__attribute((noreturn)) and __declspec(noreturn) differ in that when compiling a<br />

function definition, if the function reaches an explicit or implicit return,<br />

__attribute((noreturn)) is ignored and the compiler generates a warning. This does not<br />

apply to __declspec(noreturn).<br />

Usage<br />

Use this attribute to reduce the cost of calling a function that never returns, such as<br />

exit(). If a noreturn function returns to its caller, the behavior is undefined.<br />

Restrictions<br />

The return address is not preserved when calling the noreturn function. This limits the<br />

ability of a debugger to display the call stack.<br />

Example<br />

__declspec(noreturn) void overflow(void); // never return on overflow<br />

int negate(int x)<br />

{<br />

if (x == 0x80000000) overflow();<br />

return -x;<br />

}<br />

See also<br />

• __attribute__((noreturn)) on page 4-36.<br />

4.2.5 __declspec(nothrow)<br />

The __declspec(nothrow) attribute asserts that a call to a function never results in a C++<br />

exception being propagated from the call into the caller.<br />

The <strong>ARM</strong> library headers automatically add this qualifier to declarations of C functions<br />

that, according to the ISO C Standard, can never throw.<br />

4-28 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!