A "non-returning" function is a function which cannot return normally.
It can transfer control only through
(in C++), or similar mechanisms. The most prominent function of this
class is the
abort function. Non-returning functions are
declared with a
void return type.
It helps the compiler’s ability to emit sensible warnings, following data-flow analysis, to declare which functions are non-returning.
To decorate function declarations and function definitions, you can
_Noreturn keyword. No modules are needed, as Gnulib
<config.h> to define
_Noreturn to an
appropriate replacement on platforms lacking it.
Gnulib has two modules that support such a declaration:
_GL_NORETURN_FUNCfor use in function declarations and function definitions.
_GL_NORETURN_FUNCPTRfor use on function pointers.
The include file is
noreturnis a no-op on some platforms even though
_Noreturnworks on them. The include file is
Which of the two modules to use? If the non-returning functions you
have to declare are unlikely to be accessed through function pointers,
you should use module
stdnoreturn; otherwise the module
noreturn provides for better data-flow analysis and thus for
For a detailed description of the
stdnoreturn module, see