C/C Preprocessor

= Macros = int foo = 1024; \ foo + x;        \ })
 * The following C macro example is what GCC calls a 'statement expression'. It returns the value of the last expression in a statement block.
 * 1) define FOO(x) ({ \


 * This expression will not expand out with the '{' '}' braces.

bar = FOO(x);   \ }
 * 1) define BAR(x) { \


 * For that you need:

bat = FOO(x);     \ } while(0)
 * 1) define BAT(x) do { \

= Function definitions = BAT(z); with the following macro definition: bat = FOO(x);     \ } while(0) It will expand as: (x) { bat = FOO(x); } Which is WRONG. You need: bat = FOO(x);     \ } while(0) So that it expands as: { bat = FOO(z); }
 * If you want to redefine function foo(bar) to foo_internal(bar) the following won't work:
 * 1) define foo (bar) foo_internal (bar)
 * You must use not have a space between foo and its parameter list:
 * 1) define foo(bar) foo_internal (bar)
 * This applies for normal macro function expansions in general. When invoking:
 * 1) define BAT (x) do { \
 * 1) define BAT(x) do { \