1 #include <stdlib.h>
2
3 #ifdef PROTOTYPES
main(int argc,char ** argv,char ** envp)4 int main (int argc, char **argv, char **envp)
5 #else
6 main (argc, argv, envp)
7 int argc;
8 char **argv;
9 char **envp;
10 #endif
11 {
12 extern void dummy();
13 dummy();
14 return 0;
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 struct
119 {
120 long v_long_member;
121 struct t_struct t;
122 char v_char_member;
123 } v_struct3;
124
125 /**** unions *******/
126
127 union t_union {
128 char v_char_member;
129 short v_short_member;
130 int v_int_member;
131 long v_long_member;
132 float v_float_member;
133 double v_double_member;
134 } v_union;
135
136 union {
137 char v_char_member;
138 short v_short_member;
139 int v_int_member;
140 long v_long_member;
141 float v_float_member;
142 double v_double_member;
143 } v_union2;
144
145 /*** Functions returning type ********/
146
v_char_func()147 char v_char_func () { return(0); }
v_signed_char_func()148 signed char v_signed_char_func () { return (0); }
v_unsigned_char_func()149 unsigned char v_unsigned_char_func () { return (0); }
150
v_short_func()151 short v_short_func () { return (0); }
v_signed_short_func()152 signed short v_signed_short_func () { return (0); }
v_unsigned_short_func()153 unsigned short v_unsigned_short_func () { return (0); }
154
v_int_func()155 int v_int_func () { return (0); }
v_signed_int_func()156 signed int v_signed_int_func () { return (0); }
v_unsigned_int_func()157 unsigned int v_unsigned_int_func () { return (0); }
158
v_long_func()159 long v_long_func () { return (0); }
v_signed_long_func()160 signed long v_signed_long_func () { return (0); }
v_unsigned_long_func()161 unsigned long v_unsigned_long_func () { return (0); }
162
v_float_func()163 float v_float_func () { return (0.0); }
v_double_func()164 double v_double_func () { return (0.0); }
165
166 /**** Some misc more complicated things *******/
167
168 struct link {
169 struct link *next;
170 #ifdef __STDC__
171 struct link *(*linkfunc) (struct link *this, int flags);
172 #else
173 struct link *(*linkfunc) ();
174 #endif
175 struct t_struct stuff[1][2][3];
176 } *s_link;
177
178 union tu_link {
179 struct link *next;
180 #ifdef __STDC__
181 struct link *(*linkfunc) (struct link *this, int flags);
182 #else
183 struct link *(*linkfunc) ();
184 #endif
185 struct t_struct stuff[1][2][3];
186 } u_link;
187
188 /**** Enumerations *******/
189
190 enum colors {red, green, blue} color;
191 enum cars {chevy, ford, porsche} clunker;
192
193 /**** Enumeration bitfields, supported by GNU C *******/
194
195 #ifdef __GNUC__
196 enum senum {sm1 = -1, s1 = 1};
197 struct senum_field {enum senum field:2; } sef;
198 enum uenum {u1 = 1, u2 = 2};
199 struct uenum_field {enum uenum field:2; } uef;
200 #endif
201
202 void
dummy()203 dummy ()
204 {
205 /* setvar.exp wants to allocate memory for constants. So make sure malloc
206 gets linked into the program. */
207 malloc (1);
208
209 /* Some linkers (e.g. on AIX) remove unreferenced variables,
210 so make sure to reference them. */
211 v_char = 0;
212 v_signed_char = 1;
213 v_unsigned_char = 2;
214
215 v_short = 3;
216 v_signed_short = 4;
217 v_unsigned_short = 5;
218
219 v_int = 6;
220 v_signed_int = 7;
221 v_unsigned_int = 8;
222
223 v_long = 9;
224 v_signed_long = 10;
225 v_unsigned_long = 11;
226
227 v_float = 100.0;
228 v_double = 200.0;
229
230
231 v_char_array[0] = v_char;
232 v_signed_char_array[0] = v_signed_char;
233 v_unsigned_char_array[0] = v_unsigned_char;
234
235 v_short_array[0] = v_short;
236 v_signed_short_array[0] = v_signed_short;
237 v_unsigned_short_array[0] = v_unsigned_short;
238
239 v_int_array[0] = v_int;
240 v_signed_int_array[0] = v_signed_int;
241 v_unsigned_int_array[0] = v_unsigned_int;
242
243 v_long_array[0] = v_long;
244 v_signed_long_array[0] = v_signed_long;
245 v_unsigned_long_array[0] = v_unsigned_long;
246
247 v_float_array[0] = v_float;
248 v_double_array[0] = v_double;
249
250 v_char_pointer = &v_char;
251 v_signed_char_pointer = &v_signed_char;
252 v_unsigned_char_pointer = &v_unsigned_char;
253
254 v_short_pointer = &v_short;
255 v_signed_short_pointer = &v_signed_short;
256 v_unsigned_short_pointer = &v_unsigned_short;
257
258 v_int_pointer = &v_int;
259 v_signed_int_pointer = &v_signed_int;
260 v_unsigned_int_pointer = &v_unsigned_int;
261
262 v_long_pointer = &v_long;
263 v_signed_long_pointer = &v_signed_long;
264 v_unsigned_long_pointer = &v_unsigned_long;
265
266 v_float_pointer = &v_float;
267 v_double_pointer = &v_double;
268
269 color = red;
270 clunker = porsche;
271
272 u_link.next = s_link;
273
274 v_struct2.v_int_member = v_struct1.v_int_member;
275 v_union2.v_short_member = v_union.v_short_member;
276
277 #ifdef __GNUC__
278 sef.field = s1;
279 uef.field = u1;
280 #endif
281 }
282