void sbs(){
exit(0);
}
warning:
function might be possible candidate for attribute ‘noreturn’
Getting a warning as no return.. But here the return is not called, instead exit(0) is called.
void sbs(){
exit(0);
}
warning:
function might be possible candidate for attribute ‘noreturn’
Getting a warning as no return.. But here the return is not called, instead exit(0) is called.
The warning is completely legit.
Attribute noreturn
means you should write your prototype like this:
C11:
_Noreturn void neverreturn()
_Noreturn
is the attribute.
or the GCC variant:
__attribute__((__noreturn__)) void neverreturn()
Here its obviously __noreturn__
.
With this the compiler can make optimizations because it knows the function never will return.
As mentioned by others ,your function should give the indication to compiler that it will not return to the caller.
Please check the bellow links.