GNU Info

Info Node: (cpp-295.info)Macro Pitfalls

(cpp-295.info)Macro Pitfalls


Prev: Redefining Up: Macros
Enter node , (file) or (file)node

Pitfalls and Subtleties of Macros
---------------------------------

   In this section we describe some special rules that apply to macros
and macro expansion, and point out certain cases in which the rules have
counterintuitive consequences that you must watch out for.

Misnesting
Macros can contain unmatched parentheses.
Macro Parentheses
Why apparently superfluous parentheses
may be necessary to avoid incorrect grouping.
Swallow Semicolon
Macros that look like functions
but expand into compound statements.
Side Effects
Unsafe macros that cause trouble when
arguments contain side effects.
Self-Reference
Macros whose definitions use the macros' own names.
Argument Prescan
Actual arguments are checked for macro calls
before they are substituted.
Cascaded Macros
Macros whose definitions use other macros.
Newlines in Args
Sometimes line numbers get confused.

automatically generated by info2www version 1.2.2.9