A while ago I have discovered an (rather ancient) C Compiler, which scanned macros this way (Pseudo code):
if line.startswith(\"#include\") or line.startswi
I don't think the compiler "cares" if you have spaces before the preprocessed - it should be the same...
No, they don't need to be at the beginning of the line, but they can only have blanks (spaces, tabs, ...) before them.
Usually they're put at the beginning of the line because they're not subjected to the scopes they're into, since they're preprocessed before actual C code.
Doesn't matter. See it this way, if code was not idented and in 1 line it still should compile(only code, preprocessor/includes at some other things needs a seperate line).
Edit: seems to be that really old compiler are picky about this. Preprocessor should be at one line, just like other non-code things like includes
from gcc C preprocessor documentation:
Preprocessing directives are lines in your program that start with
#'. Whitespace is allowed before and after the
#'.
Some old C compilers required that the #define
(for example) be flush with the left margin:
#define FOO bar
Other C compilers required only that the #
be at the left margin, so you could:
# define FOO bar
Newer C compilers tend to accept the #
after any leading whitespace:
#define FOO bar
If you want compatibility with such older compilers, you should at least put your #
in the first column. If compatibility doesn't matter, then it's up to you.
I would usually try not to embed #ifdef
blocks inside functions, so the whole question of whether they should be indented mostly goes away.