Whole document tree
    

Whole document tree

The C Preprocessor: Macro Pitfalls
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.4.8 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.

1.4.8.1 Improperly Nested Constructs  Macros can contain unmatched parentheses.
1.4.8.2 Unintended Grouping of Arithmetic  Why apparently superfluous parentheses may be necessary to avoid incorrect grouping.
1.4.8.3 Swallowing the Semicolon  Macros that look like functions but expand into compound statements.
1.4.8.4 Duplication of Side Effects  Unsafe macros that cause trouble when arguments contain side effects.
1.4.8.5 Self-Referential Macros  Macros whose definitions use the macros' own names.
1.4.8.6 Separate Expansion of Macro Arguments  Actual arguments are checked for macro calls before they are substituted.
1.4.8.7 Cascaded Use of Macros  Macros whose definitions use other macros.
1.4.9 Newlines in Macro Arguments  Sometimes line numbers get confused.



This document was generated by root on January, 30 2002 using texi2html