Predefined Macros

suggest change

A predefined macro is a macro that is already understood by the C pre processor without the program needing to define it. Examples include

Mandatory Pre-Defined Macros

There’s also a related predefined identifier, __func__ (ISO/IEC 9899:2011 §, which is not a macro:

The identifier __func__ shall be implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration:
static const char __func__[] = "function-name";

appeared, where function-name is the name of the lexically-enclosing function.

__FILE__, __LINE__ and __func__ are especially useful for debugging purposes. For example:

fprintf(stderr, "%s: %s: %d: Denominator is 0", __FILE__, __func__, __LINE__);

Pre-C99 compilers, may or may not support __func__ or may have a macro that acts the same that is named differently. For example, gcc used __FUNCTION__ in C89 mode.

The below macros allow to ask for detail on the implementation:

Other Pre-Defined Macros (non mandatory)

ISO/IEC 9899:2011 § Environment macros:

ISO/IEC 9899:2011 § Conditional feature macros

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents