This tip has been extracted from the main preprocessor arithmetic article.
Preprocessor macros (created with #define directives) define a replacement string. Any macros appearing in C source code are replaced with this string. The string then forms part of a larger C expression and is interpreted and evaluated by the compiler in the usual way.
The preprocessor sees the replacement string as nothing more than characters; it does not parse the string, there is no concept of types or values, and the preprocessor does not evaluate anything resembling an expression.
However, there is one instance where the preprocessor will evaluate expressions, and that is when they appear as the controlling expression of #if or #elif conditional directives, such as in the first line of the following example.
Note that the preprocessor assigns types to integer constants that are different to those assigned by the C compiler. These types typically have different sizes, and hence results obtained by the preprocessor might not be the same as those produced by the compiler for the same expressions appearing in C code.
Take care with preprocessor expression evaluation, especially if you have macros which are used in both C code and as the controlling expression of a preprocessor conditional directive.
Microchip Technology acquires Atmel