The C Standard, 7.1.4 paragraph 1, [ISO/IEC 9899:20112024] states
Any function declared in a header may be additionally implemented as a function-like macro defined defined in the header, so if a library function is declared explicitly when its header is included, one of the techniques shown below later in the next subclause can be used to ensure the declaration is not affected by such a macro. Any macro definition definition of a function can be suppressed locally by enclosing the name of the function in parentheses, because the name is then not followed by the left parenthesis that indicates expansion of a macro function name. For the same syntactic reason, it is permitted to take the address of a library function even if it is also defined defined as a macro.185 220) The use of #undef to remove any macro definition will also ensure that an actual function is referred to.
220185)This means that an implementation shall is required to provide an actual function for each library function, even if it also provides a macro for that function.
However, the C Standard enumerates specific exceptions in which the behavior of accessing an object or function expanded to be a standard library macro definition is undefined. The macros are assert
, errno
, math_errhandling
, setjmp
, va_arg
, va_copy
, va_end
, and va_start
. These cases are described by undefined behaviors 110, 114, 122, 124, and 138. Programmers must not suppress these macros to access the underlying object or function.
...
Bibliography
ISO/IEC 9899:20112024 | 7.1.4, "Use of Library Functions" |
...