Non-returning function
From cppreference.com
The C programming language, as of C11, supports non-returning functions with the built-in type _Noreturn
(see _Noreturn). When the header <stdnoreturn.h>
is included, the non-returning function is also accessible as noreturn.
[edit] Macros
Macro name | Expands to |
noreturn
|
_Noreturn |
[edit] Example
Run this code
#include <stdlib.h> #include <stdio.h> noreturn void stop_now() { abort(); } int main(void) { printf("Preparing to stop...\n"); stop_now(); printf("This code is never executed.\n"); return EXIT_SUCCESS; }
Possible output:
Preparing to stop... Abort
[edit] See also
C++ documentation for noreturn
|