Commit | Line | Data |
---|---|---|
085dd6e6 JM |
1 | #ifdef PROTOTYPES |
2 | int main (int argc, char **argv, char **envp) | |
3 | #else | |
c906108c SS |
4 | main (argc, argv, envp) |
5 | int argc; | |
6 | char **argv; | |
7 | char **envp; | |
085dd6e6 | 8 | #endif |
c906108c SS |
9 | { |
10 | extern void dummy(); | |
c906108c | 11 | dummy(); |
085dd6e6 JM |
12 | return 0; |
13 | ||
c906108c SS |
14 | } |
15 | ||
16 | /* We put main() right up front so its line number doesn't keep changing. */ | |
17 | ||
18 | /* | |
19 | * Test file with lots of different types, for testing the | |
20 | * "whatis" command. | |
21 | */ | |
22 | ||
23 | /* | |
24 | * First the basic C types. | |
25 | */ | |
26 | ||
27 | #if !defined (__STDC__) && !defined (_AIX) | |
28 | #define signed /**/ | |
29 | #endif | |
30 | ||
31 | char v_char; | |
32 | signed char v_signed_char; | |
33 | unsigned char v_unsigned_char; | |
34 | ||
35 | short v_short; | |
36 | signed short v_signed_short; | |
37 | unsigned short v_unsigned_short; | |
38 | ||
39 | int v_int; | |
40 | signed int v_signed_int; | |
41 | unsigned int v_unsigned_int; | |
42 | ||
43 | long v_long; | |
44 | signed long v_signed_long; | |
45 | unsigned long v_unsigned_long; | |
46 | ||
47 | float v_float; | |
48 | double v_double; | |
c906108c SS |
49 | /* |
50 | * Now some derived types, which are arrays, functions-returning, | |
51 | * pointers, structures, unions, and enumerations. | |
52 | */ | |
53 | ||
54 | /**** arrays *******/ | |
55 | ||
56 | char v_char_array[2]; | |
57 | signed char v_signed_char_array[2]; | |
58 | unsigned char v_unsigned_char_array[2]; | |
59 | ||
60 | short v_short_array[2]; | |
61 | signed short v_signed_short_array[2]; | |
62 | unsigned short v_unsigned_short_array[2]; | |
63 | ||
64 | int v_int_array[2]; | |
65 | signed int v_signed_int_array[2]; | |
66 | unsigned int v_unsigned_int_array[2]; | |
67 | ||
68 | long v_long_array[2]; | |
69 | signed long v_signed_long_array[2]; | |
70 | unsigned long v_unsigned_long_array[2]; | |
71 | ||
72 | float v_float_array[2]; | |
73 | double v_double_array[2]; | |
941b2081 JK |
74 | |
75 | /**** initialized array *******/ | |
76 | ||
77 | int v_int_array_init[2] = { 10, 20 }; | |
78 | ||
c906108c SS |
79 | /**** pointers *******/ |
80 | ||
81 | char *v_char_pointer; | |
82 | signed char *v_signed_char_pointer; | |
83 | unsigned char *v_unsigned_char_pointer; | |
84 | ||
85 | short *v_short_pointer; | |
86 | signed short *v_signed_short_pointer; | |
87 | unsigned short *v_unsigned_short_pointer; | |
88 | ||
89 | int *v_int_pointer; | |
90 | signed int *v_signed_int_pointer; | |
91 | unsigned int *v_unsigned_int_pointer; | |
92 | ||
93 | long *v_long_pointer; | |
94 | signed long *v_signed_long_pointer; | |
95 | unsigned long *v_unsigned_long_pointer; | |
96 | ||
97 | float *v_float_pointer; | |
98 | double *v_double_pointer; | |
99 | ||
100 | /**** structs *******/ | |
101 | ||
102 | struct t_struct { | |
103 | char v_char_member; | |
104 | short v_short_member; | |
105 | int v_int_member; | |
106 | long v_long_member; | |
107 | float v_float_member; | |
108 | double v_double_member; | |
109 | } v_struct1; | |
110 | ||
111 | struct { | |
112 | char v_char_member; | |
113 | short v_short_member; | |
114 | int v_int_member; | |
115 | long v_long_member; | |
116 | float v_float_member; | |
117 | double v_double_member; | |
118 | } v_struct2; | |
119 | ||
120 | /**** unions *******/ | |
121 | ||
122 | union t_union { | |
123 | char v_char_member; | |
124 | short v_short_member; | |
125 | int v_int_member; | |
126 | long v_long_member; | |
127 | float v_float_member; | |
128 | double v_double_member; | |
129 | } v_union; | |
130 | ||
131 | union { | |
132 | char v_char_member; | |
133 | short v_short_member; | |
134 | int v_int_member; | |
135 | long v_long_member; | |
136 | float v_float_member; | |
137 | double v_double_member; | |
138 | } v_union2; | |
139 | ||
140 | /*** Functions returning type ********/ | |
141 | ||
142 | char v_char_func () { return(0); } | |
143 | signed char v_signed_char_func () { return (0); } | |
144 | unsigned char v_unsigned_char_func () { return (0); } | |
145 | ||
146 | short v_short_func () { return (0); } | |
147 | signed short v_signed_short_func () { return (0); } | |
148 | unsigned short v_unsigned_short_func () { return (0); } | |
149 | ||
150 | int v_int_func () { return (0); } | |
151 | signed int v_signed_int_func () { return (0); } | |
152 | unsigned int v_unsigned_int_func () { return (0); } | |
153 | ||
154 | long v_long_func () { return (0); } | |
155 | signed long v_signed_long_func () { return (0); } | |
156 | unsigned long v_unsigned_long_func () { return (0); } | |
157 | ||
158 | float v_float_func () { return (0.0); } | |
159 | double v_double_func () { return (0.0); } | |
160 | ||
161 | /**** Some misc more complicated things *******/ | |
162 | ||
163 | struct link { | |
164 | struct link *next; | |
165 | #ifdef __STDC__ | |
166 | struct link *(*linkfunc) (struct link *this, int flags); | |
167 | #else | |
168 | struct link *(*linkfunc) (); | |
169 | #endif | |
170 | struct t_struct stuff[1][2][3]; | |
171 | } *s_link; | |
172 | ||
173 | union tu_link { | |
174 | struct link *next; | |
175 | #ifdef __STDC__ | |
176 | struct link *(*linkfunc) (struct link *this, int flags); | |
177 | #else | |
178 | struct link *(*linkfunc) (); | |
179 | #endif | |
180 | struct t_struct stuff[1][2][3]; | |
181 | } u_link; | |
182 | ||
183 | /**** Enumerations *******/ | |
184 | ||
185 | enum colors {red, green, blue} color; | |
186 | enum cars {chevy, ford, porsche} clunker; | |
187 | ||
188 | ||
189 | void dummy() | |
190 | { | |
191 | /* Some linkers (e.g. on AIX) remove unreferenced variables, | |
192 | so make sure to reference them. */ | |
193 | v_char = 0; | |
194 | v_signed_char = 1; | |
195 | v_unsigned_char = 2; | |
196 | ||
197 | v_short = 3; | |
198 | v_signed_short = 4; | |
199 | v_unsigned_short = 5; | |
200 | ||
201 | v_int = 6; | |
202 | v_signed_int = 7; | |
203 | v_unsigned_int = 8; | |
204 | ||
205 | v_long = 9; | |
206 | v_signed_long = 10; | |
207 | v_unsigned_long = 11; | |
208 | ||
209 | v_float = 100.0; | |
210 | v_double = 200.0; | |
c906108c SS |
211 | v_char_array[0] = v_char; |
212 | v_signed_char_array[0] = v_signed_char; | |
213 | v_unsigned_char_array[0] = v_unsigned_char; | |
214 | ||
215 | v_short_array[0] = v_short; | |
216 | v_signed_short_array[0] = v_signed_short; | |
217 | v_unsigned_short_array[0] = v_unsigned_short; | |
218 | ||
219 | v_int_array[0] = v_int; | |
220 | v_signed_int_array[0] = v_signed_int; | |
221 | v_unsigned_int_array[0] = v_unsigned_int; | |
222 | ||
223 | v_long_array[0] = v_long; | |
224 | v_signed_long_array[0] = v_signed_long; | |
225 | v_unsigned_long_array[0] = v_unsigned_long; | |
226 | ||
227 | v_float_array[0] = v_float; | |
228 | v_double_array[0] = v_double; | |
c906108c SS |
229 | v_char_pointer = &v_char; |
230 | v_signed_char_pointer = &v_signed_char; | |
231 | v_unsigned_char_pointer = &v_unsigned_char; | |
232 | ||
233 | v_short_pointer = &v_short; | |
234 | v_signed_short_pointer = &v_signed_short; | |
235 | v_unsigned_short_pointer = &v_unsigned_short; | |
236 | ||
237 | v_int_pointer = &v_int; | |
238 | v_signed_int_pointer = &v_signed_int; | |
239 | v_unsigned_int_pointer = &v_unsigned_int; | |
240 | ||
241 | v_long_pointer = &v_long; | |
242 | v_signed_long_pointer = &v_signed_long; | |
243 | v_unsigned_long_pointer = &v_unsigned_long; | |
244 | ||
245 | v_float_pointer = &v_float; | |
246 | v_double_pointer = &v_double; | |
247 | ||
248 | color = red; | |
249 | clunker = porsche; | |
250 | ||
251 | u_link.next = s_link; | |
252 | ||
253 | v_struct2.v_int_member = v_struct1.v_int_member; | |
254 | v_union2.v_short_member = v_union.v_short_member; | |
255 | } |