The _Noreturn function specifier
The _Noreturn function specifier declares a function that does not return to its caller. When you declare a function with the specifier, the compiler can better optimize your code without regard to what happens if it returns. Any function, with the exception of main, can be declared or defined with the _Noreturn function specifier.
When _Noreturn is enabled, the __IBMC_NORETURN macro is defined as 1.
Include the standard header file stdnoreturn.h in your program when using the _Noreturn function specifier.
The following code fragment shows a function definition
with the _Noreturn specifier:
_Noreturn void f (void) {
abort();
}
Notes:
- The _Noreturn keyword is recognized under compilation with the -qlanglvl=extc89, -qlanglvl=extc99, -qlanglvl=extended, or -qlanglvl=extc1x compiler option.
- The _Noreturn keyword is recognized under compilation with the -qlanglvl=extended, -qlanglvl=extended0x, or -qlanglvl=c1xnoreturn compiler option.
- You can also define your own functions that never
return by using the _Noreturn function specifier.
However, any functions that are declared with _Noreturn must
call one of the following functions. Otherwise, the functions will
return the control to their respective caller.
- abort
- exit
- _Exit
- longjmp
- quick_exit
- thrd_exit