Next: , Previous: Literal Symbols, Up: Syntactic Symbols

10.2.9 Multiline Macro Symbols

Multiline preprocessor macro definitions are normally handled just like other code, i.e., the lines inside them are indented according to the syntactic analysis of the preceding lines inside the macro. The first line inside a macro definition (i.e., the line after the starting line of the cpp directive itself) gets cpp-define-intro. In this example:

      1: #define LIST_LOOP(cons, listp)                         \
      2:   for (cons = listp; !NILP (cons); cons = XCDR (cons)) \
      3:     if (!CONSP (cons))                                 \
      4:       signal_error ("Invalid list format", listp);     \
      5:     else

line 1 is given the syntactic symbol cpp-macro. The first line of a cpp directive is always given that symbol. Line 2 is given cpp-define-intro, so that you can give the macro body as a whole some extra indentation. Lines 3 through 5 are then analyzed as normal code, i.e., substatement on lines 3 and 4, and else-clause on line 5.

The syntactic analysis inside macros can be turned off with c-syntactic-indentation-in-macros (see Custom Macros). In that case, lines 2 through 5 would all be given cpp-macro-cont with an anchor position pointing to the # which starts the cpp directive1.

See Custom Macros, for more info about the treatment of macros.


Footnotes

[1] This is how CC Mode 5.28 and earlier analyzed macros.