1/* taken from ISO/IEC 9899:1999 Section 6.10.3.5 p6 */23#define str(s) # s4#define xstr(s) str(s)5#define debug(s, t) test1("x" # s "= %d, x" # t "= %d", \6 x ## s, x ## t)7#define INCFILE(n) vers ## n8#define vers2 0200-cpp9#define glue(a, b) a ## b10#define xglue(a, b) glue(a, b)11#define HIGHLOW "hello"12#define LOW LOW ", world"1314int15test1(char *s, int x, int y)16{17 int i;1819 for (i = 0; s[i]; i++) {20 if (s[i] != "x1= %d, x2= %d"[i])21 return 0;22 }23 if (x + y != 3)24 return 0;25 return 1;26}2728int29test2(char *s1, char *s2)30{31 int i;3233 for (i = 0; s1[i]; i++) {34 if (s1[i] != s2[i])35 return 0;36 }37 return s1[i] == '\0' && s2[i] == '\0';38}3940int41test4(char *s)42{43 int i;4445 for (i = 0; s[i]; i++) {46 if (s[i] != "hello"[i])47 return 0;48 }4950 return 1;51}5253int54test5(char *s)55{56 int i;5758 for (i = 0; s[i]; i++) {59 if (s[i] != "hello, world"[i])60 return 0;61 }6263 return 1;64}6566int67main()68{69 int x1 = 1, x2 = 2;70 char *s = "strncmp(\"abc\\0d\", \"abc\", '\\4') == 0: @\n";7172 if (!debug(1, 2))73 return 1;7475 if (!test2(str(strncmp("abc\0d", "abc", '\4') // this goes away76== 0) str(: @\n), s))77 return 2;7879#include xstr(INCFILE(2).h)8081 if (x != 2)82 return 3;8384 if (!test4(glue(HIGH, LOW)))85 return 4;8687 if (!test5(xglue(HIGH, LOW)))88 return 5;8990 return 0;91}