Home  >  Article  >  Backend Development  >  In C language, _Noreturn function specifier

In C language, _Noreturn function specifier

WBOY
WBOYforward
2023-08-25 22:29:15845browse

In C language, _Noreturn function specifier

_Noreturn The function specifier tells the compiler that the function will not return anything. If some return statements are used inside the program, the compiler will generate a compile-time error.

Sample Code

#include<stdio.h>
main() {
   printf("The returned value: %d</p><p>", function);
}
char function() {
   return &#39;T&#39;; //return T as character
}

Output

The program terminates abnormally
[Warning] function declared &#39;noreturn&#39; has a &#39;return&#39; statement

Now if it is a normal function it will work fine.

Sample code

#include<stdio.h>
int function() {
   return 86; //try to return a value
}
main() {
   printf("The returned value: %d</p><p>", function());
}

Output

The returned value: 86

The above is the detailed content of In C language, _Noreturn function specifier. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete