michinyon:
Unlike some other languages, C/C++ doesn't care where there are line breaks in your code, at all.
This would be legal:
if ( i==
1
||
j
==2 )
{ /* do something */ }
Not always true.
While the actual C compiler is pretty liberal, line breaks do matter particularly to the
C preprocessor.
For example.
#include "header.h"
works
#include
"header.h"
does not.
When defining complex cpp macros, line continuations are often used.
Here are few examples of function like macros that use line continuation for clarity and readability:
#define glcdio_SetRWDI(_RWstate, _DIstate) \
do { \
glcdio_WritePin(glcdPinRW, _RWstate); \
glcdio_WritePin(glcdPinDI, _DIstate); \
} while (0)
#define _glcdio_BLstate(pin, onlevel, offlevel, state)\
do { state ? glcdio_WritePin(pin, onlevel) : glcdio_WritePin(pin, offlevel) ; } while(0)
Also, line breaks matter to the compiler if inside the middle of a literal string.
Example:
char *foo = "this is a string
that continues on another line";
does not work.
To continue a line you can use the backslash character:
char *foo = "this is a string\
that continues on another line";
You also can't split up a comment delimeter across lines unless you use the line continuation:
example;
// this is a valid comment
/
/ this is not a valid comment
/\
/ this is a valid comment
(same is true for the /* */ comment delimiters)
--- bill