home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 355_03 / slk3.exe / TEST / MACRO.C < prev    next >
C/C++ Source or Header  |  1990-04-17  |  1KB  |  82 lines

  1. /* From page 93 of standard. */
  2. #define x 3
  3. #define f(a) f(x * (a))
  4. #undef x
  5.  
  6. #define x 2
  7. #define g f
  8. #define z z[0]
  9. #define h g(~
  10. #define m(a) a(w)
  11. #define w 0,1
  12. #define t(a) a
  13.  
  14. int abc;
  15.  
  16. void
  17. test1(void)
  18. {
  19.     abc = 1;
  20.  
  21.     /* PART 1
  22.     f(y+1);
  23.     f(2 * (y+1));
  24.     */
  25.     f(y+1);
  26.  
  27.     /* PART 2
  28.     f(f(z));
  29.     f(2 * (f(2 * (z[0]))));
  30.     */
  31.     f(f(z));
  32.  
  33.     /* PART 3
  34.     t(t(g)(0) + t)(1);
  35.     f(2 * (0)) + t(1);
  36.     */
  37.     t(t(g)(0) + t)(1);
  38.  
  39.     /*
  40.     g(x+(3,4)-w) | h 5) & m (f)^m(m);
  41.     should result in:
  42.     f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
  43.     the actual result is:
  44.     */
  45.     g(x+(3,4)-w) | h 5) & m (f)^m
  46.     (m);
  47. }
  48.  
  49. #define str(s) # s
  50. #define xstr(s) str(s)
  51. #define debug(s,t) printf("x" # s "=%d, x" # t "= %s", x ## s, x ##t)
  52.  
  53. void
  54. test2(void)
  55. {
  56.     abc = 2;
  57.  
  58.     debug(1,2);
  59.     fputs(str(strncmp("abc\0d", "abc", '\4') == 0 ) str(: @\n), s);
  60. }
  61.  
  62. #ifdef GARBAGE
  63.  
  64. #define OBJ_LIKE (1-1)
  65. #define OBJ_LIKE /* a */  (1-1) /* b */
  66. #define FTN_LIKE(a) ( a )
  67. #define FTN_LIKE( a ) ( /* a */ \
  68.     a  /* b
  69.     */ )
  70.  
  71.  
  72. #define OBJ_LIKE (0)
  73. #define OBJ_LIKE (1 - 1)
  74. #define FTN_LIKE(b) ( a )
  75. #define FTN_LIKE(b) (b)
  76.  
  77. #define char (signed) char
  78.  
  79. #endif
  80.  
  81. #error should be line 67
  82.