Home > Backend Development > C++ > body text

In C language, _Noreturn function specifier

WBOY
Release: 2023-08-25 22:29:15
forward
861 people have browsed it

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
}
Copy after login

Output

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

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());
}
Copy after login

Output

The returned value: 86
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template