Category
Modifiers, Keyword extensions, Storage class specifiers
Syntax
__declspec( noreturn ) declarator
This __declspec attribute tells the compiler that a function does not return. As a consequence, the compiler knows that the code following a call to a __declspec(noreturn) function is unreachable.
If the compiler finds a function with a control path that does not return a value, it generates a warning. If the control path cannot be reached due to a function that never returns, you can use __declspec(noreturn) to prevent this warning or error.
Example
Consider the following code. The else clause does not contain a return statement, so the programmer declares fatal as __declspec(noreturn) to avoid an error or warning message.
__declspec(noreturn) extern void fatal () { // Code omitted } int foo() { if(...) return 1; else if(...) return 0; else fatal(); }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|