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 >
Wrap
C/C++ Source or Header
|
1990-04-17
|
1KB
|
82 lines
/* From page 93 of standard. */
#define x 3
#define f(a) f(x * (a))
#undef x
#define x 2
#define g f
#define z z[0]
#define h g(~
#define m(a) a(w)
#define w 0,1
#define t(a) a
int abc;
void
test1(void)
{
abc = 1;
/* PART 1
f(y+1);
f(2 * (y+1));
*/
f(y+1);
/* PART 2
f(f(z));
f(2 * (f(2 * (z[0]))));
*/
f(f(z));
/* PART 3
t(t(g)(0) + t)(1);
f(2 * (0)) + t(1);
*/
t(t(g)(0) + t)(1);
/*
g(x+(3,4)-w) | h 5) & m (f)^m(m);
should result in:
f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
the actual result is:
*/
g(x+(3,4)-w) | h 5) & m (f)^m
(m);
}
#define str(s) # s
#define xstr(s) str(s)
#define debug(s,t) printf("x" # s "=%d, x" # t "= %s", x ## s, x ##t)
void
test2(void)
{
abc = 2;
debug(1,2);
fputs(str(strncmp("abc\0d", "abc", '\4') == 0 ) str(: @\n), s);
}
#ifdef GARBAGE
#define OBJ_LIKE (1-1)
#define OBJ_LIKE /* a */ (1-1) /* b */
#define FTN_LIKE(a) ( a )
#define FTN_LIKE( a ) ( /* a */ \
a /* b
*/ )
#define OBJ_LIKE (0)
#define OBJ_LIKE (1 - 1)
#define FTN_LIKE(b) ( a )
#define FTN_LIKE(b) (b)
#define char (signed) char
#endif
#error should be line 67