annotate test/macro.c @ 496:5640fb7a270d

more bugs...
author kono
date Thu, 22 Dec 2005 00:20:09 +0900
parents a379da780856
children fe37f32b552b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
1 int printf(const char *format, ...);
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
2
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
3
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
4 int heap[100];
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
5
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
6 #define car(e) (heap[(int)(e)])
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
7 #define cadr(e) (heap[((int)(e))+1])
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
8
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
9 #define TEST
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
10 int i;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
11 TEST
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
12
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 183
diff changeset
13 char *a = "test" "test";
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 183
diff changeset
14
115
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
15 #define TEST0 33
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
16 #define TEST111 TEST0
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
17
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
18 #define c(a,b) g(a+1,b+1)
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
19 #define g(a,b) printf("#0018:%d %d\n",a+1,b+1);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 177
diff changeset
20 #define d(a,b) cadr(b)+3
183
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
21 /*
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
22
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
23 #define stdio stdio
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
24 #define f(a,b) aho+a+b
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
25 f (a,b)
1d80ad165831 recursive macros
kono
parents: 180
diff changeset
26 */
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
27
311
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
28 // name concateneation
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
29
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
30 #define name(a,b) name_##b(a)
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
31
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
32 #define name_hoge(c) (c+a)
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
33
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
34
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
35
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
36 main() {
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
37 int a,b,e;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
38
115
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
39 b = heap[TEST111];
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 177
diff changeset
40 d(a,b);
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
41 a =1; b = 3;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
42 #ifndef a
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
43 c(a,
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
44 b);
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
45 /* 3,5 expected */
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
46 #endif
111
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
47 e=50; heap[51]=3; heap[3]=4;
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
48 /* 5,4 expected */
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
49 #if 0
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
50 g(car(cadr(e)),cadr(e));
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
51 #endif
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
52 #if 0
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
53 printf("#0052:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
54 #elif (1)
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
55 printf("#0054:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
56 #elif (2)
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
57 printf("#0056:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
58 #else
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
59 printf("#0058:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
60 #endif
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
61 #if 0
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
62 printf("#0061:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
63 #elif (0)
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
64 printf("#0063:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
65 #elif (0)
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
66 printf("#0065:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
67 #else
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
68 printf("#0067:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
69 #endif
491
a379da780856 cond signed/unsigned
kono
parents: 467
diff changeset
70 printf("#0069:%d\n",name(3,hoge));
172
096559f07a70 some check
kono
parents: 115
diff changeset
71 return 0;
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
72 }
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
73
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
74 #if 0
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
75 #endif /* whoeh
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
76 wohefwiehfoi */
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
77 longlong(int i,int j)
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
78 {
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
79 // long long i,j;
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
80 if (i>j) main();
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
81 }