_Noreturn in Visual C++

Shervan360 1,481 Reputation points
2022-04-07T18:37:13.507+00:00

Hello,

I cannot compile the following code in Visual C++ and GCC in VS Code.

Source of code here:
Here

191058-screenshot-2022-04-07-143411.jpg

// Compile with Warning Level4 (/W4) and /std:c11  
#include <stdio.h>  
#include <stdlib.h>  
#include <stdnoreturn.h>  
  
noreturn void fatal_error(void)  
{  
    exit(3);  
}  
_Noreturn void not_coming_back(void)  
{  
    puts("There's no coming back");  
    fatal_error();  
    return; // warning C4645 - function declared with noreturn has a return statement  
}  
void done(void)  
{  
    puts("We'll never get here");  
}  
int main(void)  
{  
    not_coming_back();  
    done(); // warning c4702 - unreachable code  
    return 0;  
}  
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,636 questions
0 comments No comments
{count} vote

0 additional answers

Sort by: Most helpful