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