a.c 379 B

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