c_noreturn.c (484B)
1 // C functions - _Noreturn function specifier (since C11)(deprecated in C23) 2 3 // Source: https://en.cppreference.com/w/c/language/noreturn.html 4 5 #include <stdio.h> 6 #include <stdlib.h> 7 #include <stdnoreturn.h> 8 9 // causes undefined behavior if i <= 0 10 // exits if i > 0 11 noreturn void exit_now(int i) // or _Noreturn void exit_now(int i) 12 { 13 if (i > 0) 14 exit(i); 15 } 16 17 int main(void) 18 { 19 puts("Preparing to exit..."); 20 exit_now(2); 21 puts("This code is never executed."); 22 } 23