annotate test/macro.c @ 647:fe23fe842b82

*** empty log message ***
author kono
date Fri, 17 Nov 2006 20:00:37 +0900
parents 4e08fbf6754b
children 0554b7f985ee
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
614
e4e007f4026d fix #deifne /* line
kono
parents: 591
diff changeset
36 #define hoge000(a) (a+a) /* hoge
e4e007f4026d fix #deifne /* line
kono
parents: 591
diff changeset
37 comment
e4e007f4026d fix #deifne /* line
kono
parents: 591
diff changeset
38 */
e4e007f4026d fix #deifne /* line
kono
parents: 591
diff changeset
39
311
38c9976863b7 swtich list fix. macro fix.
kono
parents: 304
diff changeset
40
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
41 int
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
42 main() {
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
43 int a,b,e;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
44
115
ebac635814dc fix nested macro function
kono
parents: 111
diff changeset
45 b = heap[TEST111];
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 177
diff changeset
46 d(a,b);
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
47 a =1; b = 3;
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
48 #ifndef a
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
49 c(a,
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
50 b);
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
51 /* 3,5 expected */
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
52 #endif
111
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
53 e=50; heap[51]=3; heap[3]=4;
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
54 /* 5,4 expected */
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
55 #if 0
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
56 g(car(cadr(e)),cadr(e));
7aa449aff3e6 floating point
kono
parents: 36
diff changeset
57 #endif
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
58 #if 0
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
59 printf("#0054:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
60 #elif (1)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
61 printf("#0056:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
62 #elif (2)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
63 printf("#0058:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
64 #else
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
65 printf("#0060:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
66 #endif
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
67 #if 0
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
68 printf("#0063:1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
69 #elif (0)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
70 printf("#0065:2\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
71 #elif (0)
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
72 printf("#0067:3\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
73 #else
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
74 printf("#0069:4\n");
177
352feeae4b0a macro else/ccout
kono
parents: 172
diff changeset
75 #endif
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
76 printf("#0071:%d\n",name(3,hoge));
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
77 printf("#0072:%d\n",names(3,hoge));
614
e4e007f4026d fix #deifne /* line
kono
parents: 591
diff changeset
78 printf("#0073:%d\n",hoge000(3));
172
096559f07a70 some check
kono
parents: 115
diff changeset
79 return 0;
36
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
80 }
9f89cef85b41 *** empty log message ***
kono
parents:
diff changeset
81
623
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
82 /* For GCC 2.7 and later, we can use specific type-size attributes. */
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
83 # define __intN_t(N, MODE) \
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
84 typedef int int##N##_t __attribute__ ((__mode__ (MODE)))
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
85 # define __u_intN_t(N, MODE) \
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
86 typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
87
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
88 # ifndef __int8_t_defined
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
89 # define __int8_t_defined
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
90 __intN_t (8, __QI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
91 __intN_t (16, __HI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
92 __intN_t (32, __SI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
93 __intN_t (64, __DI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
94 # endif
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
95
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
96 __u_intN_t (8, __QI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
97 __u_intN_t (16, __HI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
98 __u_intN_t (32, __SI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
99 __u_intN_t (64, __DI__);
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
100
4e08fbf6754b macro stringrise, switch unsginged mungle
kono
parents: 614
diff changeset
101
591
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
102 int tmp()
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
103 #if 0
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
104 {
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
105 return 1;
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
106 }
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
107 #else
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
108 {
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
109 return 0;
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
110 }
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
111 #endif
0497fa2e2414 *** empty log message ***
kono
parents: 542
diff changeset
112
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
113 #if 0
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
114 #endif /* whoeh
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
115 wohefwiehfoi */
542
492f06738550 working... (struct init fix)
kono
parents: 540
diff changeset
116 void longlong(int i,int j)
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
117 {
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
118 // long long i,j;
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
119 if (i>j) main();
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
120 }