Overview
Macros refer to #define
directives that specify terms that should be textually replaced by the preprocessor during compilation:
For types that don’t have literals that describe their constants, we can use compound literals on the replacement side of the macro:
Operators
The #
operator is used to stringify an argument. For example, calling foo(bar)
in the following yields "bar"
.
The ##
operator is used to concatenate tokens. For example, calling foo(bar)
in the following yields bar_init
.
Variable Argument Lists
The construct ...
provides an argument list of variable length. This set of arguments is then accessible inside the macro expansion as __VA_ARGS__
.
Bibliography
- Jens Gustedt, Modern C (Shelter Island, NY: Manning Publications Co, 2020).