A naming standard is a documented rule for choosing identifiers so related entities remain recognizable and collisions become less likely. Naming variables, functions, and types also affects code accessibility; accepted project or domain terminology may include non-Latin characters. section 9.4
Protecting macro-local names
A type-generic macro uses names such as swap_p1, swap_p2, and swap_tmp for its auxiliary variables. The swap-prefixed convention lowers the chance of clashing with surrounding user code, while the documented convention makes the protection intentional rather than accidental. section 18.3.1
#define SWAP(X, Y) \
do { \
/* These two variables have the role of function \
parameters. They ensure to evaluate the \
expression X and Y once, since these could be \
complicated lvalue expressions with evaluated \
subexpressions that have side effects. */ \
auto const swap_p1 = &(X); \
auto const swap_p2 = &(Y); \
static_assert_compatible(*swap_p1, *swap_p2, \
"to exchange values, '" \
#X "' and '" #Y \
"' must have compatible types"); \
auto swap_tmp = *swap_p1; \
*swap_p1 = *swap_p2; \
*swap_p2 = swap_tmp; \
} while (false)
Inspect the complete swap macro to see the naming convention applied alongside single evaluation and compatible-type checks. section 18.3.1
A naming standard reduces risk but cannot guarantee uniqueness: an outer name may still match a generated local name, and macro expansion then uses the newly defined local variable. section 18.3.1







