What is a function specifier in C?


In C and C++ there are some function specifiers. The function specifiers are used to specify the functions property. C++ has inline function specifier. In C there is _Noreturn function specifier. This is used to denote that one function will not return anything.

Example

 Live Demo

#include<stdio.h>
int myAdd(int a, int b){
   return a + b;
}
main() {
   int x = 10, y = 20;
   printf("The value is: %d
", myAdd(x, y)); }

Output

The value is: 30

If the _Noreturn is used it will display some warning and the program will be terminated with some error.

Example

#include<stdio.h>
_Noreturn int myAdd(int a, int b){
   return a + b;
}
main() {
   int x = 10, y = 20;
   printf("The value is: %d
", myAdd(x, y)); }

Output

[Warning] function declared 'noreturn' has a 'return' statement
[Warning] 'noreturn' function does return

Updated on: 30-Jul-2019

409 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements