1234567891011121314151617181920 |
- /* Demonstrate basic macro expansion behaviours, particularly the ability to expand twice.
- *
- * Compile with gcc -Wall -g -o a a.c
- * Execute with ./a
- */
- #include <stdio.h>
- #define A B
- #define B printf
- #define C(a,b,c) D("hello %d\n",b,c)
- #define D(x,y,z) do { \
- printf(x, y+z); \
- } while(0)
- int main(int argc, char *argv[]) {
- A("hello world\n");
- C(0, 3, 4);
- return 0;
- }
|