Preprocessor directives layout
- The preprocessor directive mark (
#
) MUST appear on the first column.
- Preprocessor directives following
#if
and #ifdef
MUST
be indented by one character:
#ifndef DEV_BSIZE
# ifdef BSIZE
# define DEV_BSIZE BSIZE
# else /* !BSIZE */
# define DEV_BSIZE 4096
# endif /* !BSIZE */
#endif /* !DEV_BSIZE */
- As shown in the previous example,
#else
and #endif
MUST
be followed by a comment describing the corresponding initial condition.
- When a directive must span over multiple lines, escaped line breaks
(
\
-newline) MUST appear on the same column. For this purposes,
tabulations MUST be used.
This is wrong:
#define XFREE(Var) \
do \
{ \
if (Var) \
free(Var); \
} \
while (0)
|
|
This is correct:
#define XFREE(Var) \
do \
{ \
if (Var) \
free(Var); \
} \
while (0)
|
|
Hint: use C-\ and C-u C-\, or M-i under Emacs.