c/language/function specifiers

Used in the declaration of functions.


 * - suggestion to the compiler to "inline" the function, making calls to it as fast as possible.
 * - specifies that the function does not return to where it was called from.

inline
The keyword is a hint given to the compiler to perform an optimization. The compiler has the freedom to ignore this request.

If the compiler inlines the function, it replaces every call of that function with the actual body (without generating a call). This avoids extra overhead created by the function call (placing data on stack and retrieving the result) but it may result in a larger executable as the code for the function has to be repeated multiple times. The result is similar to function-like macros.

The function body must be visible in the current translation unit, which makes the keyword necessary to implement functions inside a header file, i.e. without having a source file that has to be compiled and linked.

inline Example
With inlining turned off, run time is about 1.70 seconds. With inlining turned on, run time is less than a second.

_Noreturn
The keyword states that the function that follows it does not return to the function that it was called from. The compiler will typically generate a warning if a function declared with attempts to return a value.

In the example below the function is called, which causes the program to immediately terminate (unless the   signal is caught). The code with the and the  after the call to  is never executed and the execution never returns to the  function, where  was called from.

Keywords
,