#ifdef THISOS # include A #else # include B #endif gcc -DTHISOS -UFOO what about a 3rd OS? CPP: simple textual replacement of tokens! CPP performs TOKEN replacement #define P x won't replace 'P' in PORT=1024; - pros vs. cons: speed code bloat CPP "function-like" macros, but not same semantics as real functions ------------------------------------------------------------------------------ - why you need to (enclose) variables in ()? #define check(x) if (x && y()) printf("something") call as check(a() || b()) becomes if (a() || b() && y()) printf("something") "a || b" is NOT evaluated first! (side effects could change behaviour) - solution: #define check(x) if ((x) && y()) printf("something") ------------------------------------------------------------------------------ pitfalls a[x,y] vs. a[x][y] (comma operator in C)