GENERAL: CARRYING A #DEFINE MACRO OVER TO THE NEXT LINE
Information in this article applies to:
I'm analyzing a .C source file made by another programmer that has a #define macro definition longer than 30 lines. At the end of each line I found a backslash return character sequence ( "\" ). What does this sequence mean and how does the environment deal with it?
The backslash character ('\') is the line continuation character. It must be the last character on a line. The preprocessor joins lines ending with a line continuation character into a single line (for purposes of preprocessing and compilation).
When you create a macro that is very long it is easier to read if the macro definition is split into multiple lines. The line continuation character allows this.
#define CALC ( a , b ) \ ( ( a * b ) + ( a - 2 ) - \ ( b * 2 ) )
The above example is equivalent to.:
#define CALC ( a , b ) ( ( a * b ) + ( a - 2 ) - ( b * 2 ) )
Last Reviewed: Tuesday, June 29, 2004
of your data.