scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0273-cpp.c (524B)


      1 #define a(x) #   x
      2 
      3 static char *s = a ( 3
      4 2);
      5 
      6 static int
      7 cmp(char *s1, char *s2)
      8 {
      9 	while (*s1 && *s2 && *s1 == *s2)
     10 		++s1, ++s2;
     11 	return *s1 == '\0' && *s2 == '\0';
     12 }
     13 
     14 int
     15 main(void)
     16 {
     17 	if (!cmp(a(3), "3"))
     18 		return 1;
     19 	if (!cmp(a( 3 ), "3"))
     20 		return 2;
     21 	if (!cmp(a( 3  2 ), "3 2"))
     22 		return 3;
     23 	if (!cmp(s, "3 2"))
     24 		return 4;
     25 	if (!cmp(a("3 2  1\n"), "\"3 2  1\\n\""))
     26 		return 5;
     27 	if (!cmp(a('\n'), "'\\n'"))
     28 		return 6;
     29 	if (!cmp(a('"'), "'\"'"))
     30 		return 6;
     31 	if (!cmp(a(: @\n), ": @\n"))
     32 		return 7;
     33 
     34 	return 0;
     35 }