noreturn
Visual Studio 2010
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 (C4715) or error message (C2202). 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.
Note
|
|---|
|
Adding __declspec(noreturn) to a function that is expected to return can result in undefined behavior. |
Poor choice of function in the example
As the standard defined behavior for the main function is to add "return 0" implicitly when reaching an end of it, removing the modifier will have no effect here. However for any other function it will be certainly recommended.
- 12/1/2011
- Łukasz Mendakiewicz
Note