What is the _Noreturn in C?

The _Noreturn function specifier in C tells the compiler that the function will not return. A function returns by reaching the end of the function body or executing the return statement.

Function specifiers in C are used to specify the properties of a function.

To use the _Noreturn function specifier, include the stdlib.h header file in the program, as shown below:

#include <stdlib.h>

Syntax

We specify the _Noreturn keyword before the function declaration in the following way:

Example

The code below shows the _Noreturn function specifier without a return statement. In line 7, the exit() function is used since it does not have a return value.

The code executes without any warnings, as we see below:

#include <stdio.h>
#include <stdlib.h>
// Function Declaration
_Noreturn void test_func() {
printf ("Function Entered!");
exit(0);
}
int main() {
//Call the function test_func
test_func();
return 0;
}

The code below shows the use of the _Noreturn function specifier with a return statement.

The code executes with a compile-time error, as we see below:

#include <stdio.h>
#include <stdlib.h>
// Function Declaration
_Noreturn void test_func() {
printf ("Function entered!");
}
int main() {
//Call the function test_func
test_func();
return 0;
}

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved