Const and Volatile Functions (Using the GNU Compiler Collection (GCC))

#### 6.13.5 Const and Volatile Functions ¶

The C standard explicitly leaves the behavior of the `const` and `volatile` type qualifiers applied to functions undefined; these constructs can only arise through the use of `typedef`. As an extension, GCC defines this use of the `const` qualifier to have the same meaning as the GCC `const` function attribute, and the `volatile` qualifier to be equivalent to the `noreturn` attribute. See Common Attributes, for more information.

As examples of this usage,

    /* Equivalent to:
       void fatal () __attribute__ ((noreturn));  */
    typedef void voidfn ();
    volatile voidfn fatal;

    /* Equivalent to:
       extern int square (int) __attribute__ ((const));  */
    typedef int intfn (int);
    extern const intfn square;

In general, using function attributes instead is preferred, since the attributes make both the intent of the code and its reliance on a GNU extension explicit. Additionally, using `const` and `volatile` in this way is specific to GNU C and does not work in GNU C++.