cpp_noreturn.cpp (420B)
1 // C++ attributes - noreturn (since C++11) 2 3 // Source: https://en.cppreference.com/w/c/language/noreturn.html [modified by Vim Project] 4 5 #include <stdio.h> 6 #include <stdlib.h> 7 8 [[noreturn]] void error_exit(const char* reason) 9 { 10 printf("Error: %s\n", reason); 11 exit(1); 12 } 13 14 int main(void) 15 { 16 puts("Preparing to exit..."); 17 error_exit("Assume something is wrong"); 18 puts("This code is never executed."); 19 } 20