Predefined macros
suggest changeEvery conforming implementation provides macros that describe the translation and implementation environment.
Source-location and translation macros
__FILE__expands to the presumed source-file name as a string literal.__LINE__expands to the current presumed source-line number.__DATE__and__TIME__describe the translation date and time.__STDC__expands to1for a conforming implementation.__STDC_HOSTED__is1for a hosted implementation and0for a freestanding one.__STDC_VERSION__identifies the supported C revision when it is defined.
Common __STDC_VERSION__ values include:
| Revision | Value |
|---|---|
| C95 | 199409L |
| C99 | 199901L |
| C11 | 201112L |
| C17 | 201710L |
| C23 | 202311L |
C90 does not define __STDC_VERSION__. An implementation may also use a newer value for a later revision.
__func__ is a predefined identifier, not a macro. Inside each function, it behaves as though an array containing the function's unqualified name had been declared:
fprintf(stderr, "%s:%d: %s: invalid value\n",
__FILE__, __LINE__, __func__);
Avoid embedding __DATE__ or __TIME__ when reproducible builds matter because their values can make otherwise identical builds differ.
Conditional feature macros
Depending on the language version and implementation, macros can describe optional facilities or environmental properties. Examples include:
__STDC_NO_ATOMICS____STDC_NO_THREADS____STDC_NO_VLA____STDC_IEC_60559_BFP____STDC_UTF_16____STDC_UTF_32__
Test a feature macro with #if defined(...) before reading its value unless the selected standard guarantees that the macro is defined. The available names and their meanings changed across C revisions, so consult the documentation for the language mode and implementation being targeted.