OAR

RTEMS GNU Tools On-Line Library


Macro Pitfalls

PREV UP next Bookshelf The C Preprocessor

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.

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

  • PREV UP next Bookshelf The C Preprocessor

    Packaging copyright © 1988-2000 OAR Corporation
    Context copyright by each document's author. See Free Software Foundation for information.