annotate test/macro.c @ 542:492f06738550

working... (struct init fix)
author kono
date Sun, 01 Jan 2006 18:49:07 +0900 (2006-01-01)
parents fe37f32b552b
children 0497fa2e2414
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
540
fe37f32b552b include_next, macro_function eat 1 char.
kono
parents: 491
diff changeset
32 #define names(a,b) name_ ## b(a)
fe37f32b552b include_next, macro_function eat 1 char.
kono
parents: 491
diff changeset
33
311
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
34 #define name_hoge(c) (c+a)
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
35
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
36
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
37 int
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
38 main() {
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
39 int a,b,e;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
40
115
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
41 b = heap[TEST111];
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 177
diff changeset
42 d(a,b);
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
43 a =1; b = 3;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
44 #ifndef a
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
45 c(a,
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
46 b);
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
47 /* 3,5 expected */
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
48 #endif
111
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
49 e=50; heap[51]=3; heap[3]=4;
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
50 /* 5,4 expected */
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
51 #if 0
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
52 g(car(cadr(e)),cadr(e));
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
53 #endif
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
54 #if 0
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
55 printf("#0054:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
56 #elif (1)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
57 printf("#0056:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
58 #elif (2)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
59 printf("#0058:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
60 #else
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
61 printf("#0060:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
62 #endif
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
63 #if 0
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
64 printf("#0063:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
65 #elif (0)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
66 printf("#0065:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
67 #elif (0)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
68 printf("#0067:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
69 #else
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
70 printf("#0069:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
71 #endif
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
72 printf("#0071:%d\n",name(3,hoge));
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
73 printf("#0072:%d\n",names(3,hoge));
172
096559f07a70 some check
kono
parents: 115
diff changeset
74 return 0;
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
75 }
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
76
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
77 #if 0
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
78 #endif /* whoeh
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
79 wohefwiehfoi */
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
80 void longlong(int i,int j)
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
81 {
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
82 // long long i,j;
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
83 if (i>j) main();
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
84 }