[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Macro Handling

Preprocessor directives are handled as syntactic whitespace from other code, i.e. they can be interspersed anywhere without affecting the syntactic analysis, just like comments.

The code inside macro definitions is still analyzed syntactically so that you get relative indentation there just as you'd get if the same code was outside a macro. However, since there is no hint about the syntactic context, i.e. whether the macro expands to an expression, to some statements, or perhaps to whole functions, the syntactic recognition can be wrong. CC Mode manages to figure it out correctly most of the time, though. See section 10. Syntactic Symbols, for details about the indentation.

User Option: c-syntactic-indentation-in-macros
Enable syntactic analysis inside macros, which is the default. If this is nil, all lines inside macro definitions are analyzed as cpp-macro-cont.

CC Mode provides some tools to help keep the line continuation backslashes in macros neat and tidy:

C-c C-\ (c-backslash-region)
This function inserts and aligns or deletes the end-of-line backslashes in the current region.

With no prefix argument, it inserts any missing backslashes and aligns them according to the c-backslash-column and c-backslash-max-column variables. With a prefix argument, it deletes any backslashes.

The function does not modify blank lines at the start of the region. If the region ends at the start of a line, it always deletes the backslash (if any) at the end of the previous line.

User Option: c-backslash-column
User Option: c-backslash-max-column
These variables control the alignment columns for line continuation backslashes in multiline macros. They are used by the functions that automatically insert or align such backslashes, e.g. c-backslash-region and c-context-line-break.

c-backslash-column specifies the minimum column for the backslashes. If any line in the macro exceeds it then the next tab stop from that line is used as the alignment column for all the backslashes, so that they remain in a single column. However, if some lines exceed c-backslash-max-column then the backslashes in the rest of the macro will be kept at that column, so that the lines which are too long "stick out" instead.

User Option: c-auto-align-backslashes
Align automatically inserted line continuation backslashes if non-nil. When line continuation backslashes are inserted automatically for line breaks in multiline macros, e.g. by c-context-line-break, they are aligned with the other backslashes in the same macro if this flag is set. Otherwise the inserted backslashes are preceded by a single space.

The recommended line breaking function, c-context-line-break (see section 5. Text Filling and Line Breaking), is especially nice if you edit multiline macros frequently. When used inside a macro, it automatically inserts and adjusts the mandatory backslash at the end of the line to keep the macro together, and it leaves the point at the right indentation column for the code. Thus you can write code inside macros almost exactly as you can elsewhere, without having to bother with the trailing backslashes.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.