]>
Commit | Line | Data |
---|---|---|
5538ada6 | 1 | /* CPP Library. |
5e7b4e25 JL |
2 | Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
3 | 1999, 2000 Free Software Foundation, Inc. | |
5538ada6 ZW |
4 | Contributed by Per Bothner, 1994-95. |
5 | Based on CCCP program by Paul Rubin, June 1986 | |
6 | Adapted to ANSI C, Richard Stallman, Jan 1987 | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU General Public License as published by the | |
10 | Free Software Foundation; either version 2, or (at your option) any | |
11 | later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
5538ada6 ZW |
22 | #include "config.h" |
23 | #include "system.h" | |
24 | ||
6de1e2a9 ZW |
25 | #include "cpplib.h" |
26 | #include "cpphash.h" | |
27 | #include "output.h" | |
28 | #include "prefix.h" | |
29 | #include "intl.h" | |
9f8f4efe | 30 | #include "version.h" |
49e6c08e | 31 | #include "mkdeps.h" |
6de1e2a9 ZW |
32 | |
33 | /* Predefined symbols, built-in macros, and the default include path. */ | |
34 | ||
35 | #ifndef GET_ENV_PATH_LIST | |
36 | #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0) | |
37 | #endif | |
38 | ||
6de1e2a9 ZW |
39 | #ifndef STANDARD_INCLUDE_DIR |
40 | #define STANDARD_INCLUDE_DIR "/usr/include" | |
41 | #endif | |
42 | ||
6de1e2a9 ZW |
43 | /* We let tm.h override the types used here, to handle trivial differences |
44 | such as the choice of unsigned int or long unsigned int for size_t. | |
45 | When machines start needing nontrivial differences in the size type, | |
46 | it would be best to do something here to figure out automatically | |
47 | from other information what type to use. */ | |
48 | ||
49 | /* The string value for __SIZE_TYPE__. */ | |
50 | ||
51 | #ifndef SIZE_TYPE | |
52 | #define SIZE_TYPE "long unsigned int" | |
53 | #endif | |
54 | ||
55 | /* The string value for __PTRDIFF_TYPE__. */ | |
56 | ||
57 | #ifndef PTRDIFF_TYPE | |
58 | #define PTRDIFF_TYPE "long int" | |
59 | #endif | |
60 | ||
61 | /* The string value for __WCHAR_TYPE__. */ | |
62 | ||
63 | #ifndef WCHAR_TYPE | |
64 | #define WCHAR_TYPE "int" | |
65 | #endif | |
6de1e2a9 ZW |
66 | |
67 | /* The string value for __USER_LABEL_PREFIX__ */ | |
68 | ||
69 | #ifndef USER_LABEL_PREFIX | |
70 | #define USER_LABEL_PREFIX "" | |
71 | #endif | |
72 | ||
73 | /* The string value for __REGISTER_PREFIX__ */ | |
74 | ||
75 | #ifndef REGISTER_PREFIX | |
76 | #define REGISTER_PREFIX "" | |
77 | #endif | |
78 | ||
0b22d65c ZW |
79 | /* This is the default list of directories to search for include files. |
80 | It may be overridden by the various -I and -ixxx options. | |
81 | ||
82 | #include "file" looks in the same directory as the current file, | |
83 | then this list. | |
84 | #include <file> just looks in this list. | |
85 | ||
86 | All these directories are treated as `system' include directories | |
87 | (they are not subject to pedantic warnings in some cases). */ | |
88 | ||
455d2586 | 89 | struct default_include |
0b22d65c | 90 | { |
bcc5cac9 KG |
91 | const char *fname; /* The name of the directory. */ |
92 | const char *component; /* The component containing the directory | |
0b22d65c | 93 | (see update_path in prefix.c) */ |
6de1e2a9 ZW |
94 | int cplusplus; /* Only look here if we're compiling C++. */ |
95 | int cxx_aware; /* Includes in this directory don't need to | |
96 | be wrapped in extern "C" when compiling | |
c45da1ca | 97 | C++. */ |
455d2586 ZW |
98 | }; |
99 | ||
100 | static const struct default_include include_defaults_array[] | |
6de1e2a9 | 101 | #ifdef INCLUDE_DEFAULTS |
0b22d65c | 102 | = INCLUDE_DEFAULTS; |
6de1e2a9 | 103 | #else |
0b22d65c | 104 | = { |
6de1e2a9 ZW |
105 | /* Pick up GNU C++ specific include files. */ |
106 | { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, | |
107 | #ifdef CROSS_COMPILE | |
108 | /* This is the dir for fixincludes. Put it just before | |
109 | the files that we fix. */ | |
110 | { GCC_INCLUDE_DIR, "GCC", 0, 0 }, | |
111 | /* For cross-compilation, this dir name is generated | |
112 | automatically in Makefile.in. */ | |
0b22d65c | 113 | { CROSS_INCLUDE_DIR, "GCC", 0, 0 }, |
6de1e2a9 ZW |
114 | #ifdef TOOL_INCLUDE_DIR |
115 | /* This is another place that the target system's headers might be. */ | |
116 | { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 }, | |
117 | #endif | |
118 | #else /* not CROSS_COMPILE */ | |
119 | #ifdef LOCAL_INCLUDE_DIR | |
120 | /* This should be /usr/local/include and should come before | |
121 | the fixincludes-fixed header files. */ | |
122 | { LOCAL_INCLUDE_DIR, 0, 0, 1 }, | |
123 | #endif | |
124 | #ifdef TOOL_INCLUDE_DIR | |
125 | /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here. | |
126 | Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */ | |
127 | { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 }, | |
128 | #endif | |
129 | /* This is the dir for fixincludes. Put it just before | |
130 | the files that we fix. */ | |
131 | { GCC_INCLUDE_DIR, "GCC", 0, 0 }, | |
132 | /* Some systems have an extra dir of include files. */ | |
133 | #ifdef SYSTEM_INCLUDE_DIR | |
134 | { SYSTEM_INCLUDE_DIR, 0, 0, 0 }, | |
135 | #endif | |
136 | #ifndef STANDARD_INCLUDE_COMPONENT | |
137 | #define STANDARD_INCLUDE_COMPONENT 0 | |
138 | #endif | |
139 | { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 }, | |
140 | #endif /* not CROSS_COMPILE */ | |
141 | { 0, 0, 0, 0 } | |
0b22d65c | 142 | }; |
6de1e2a9 ZW |
143 | #endif /* no INCLUDE_DEFAULTS */ |
144 | ||
145 | /* Internal structures and prototypes. */ | |
146 | ||
0b22d65c ZW |
147 | /* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros |
148 | switch. There are four lists: one for -D and -U, one for -A, one | |
149 | for -include, one for -imacros. `undef' is set for -U, clear for | |
150 | -D, ignored for the others. | |
151 | (Future: add an equivalent of -U for -A) */ | |
152 | struct pending_option | |
6de1e2a9 | 153 | { |
0b22d65c | 154 | struct pending_option *next; |
6de1e2a9 | 155 | char *arg; |
0b22d65c | 156 | int undef; |
6de1e2a9 | 157 | }; |
0b22d65c ZW |
158 | |
159 | #ifdef __STDC__ | |
160 | #define APPEND(pend, list, elt) \ | |
161 | do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \ | |
162 | else (pend)->list##_tail->next = (elt); \ | |
163 | (pend)->list##_tail = (elt); \ | |
164 | } while (0) | |
165 | #else | |
166 | #define APPEND(pend, list, elt) \ | |
167 | do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \ | |
168 | else (pend)->list/**/_tail->next = (elt); \ | |
169 | (pend)->list/**/_tail = (elt); \ | |
170 | } while (0) | |
171 | #endif | |
6de1e2a9 | 172 | |
6de1e2a9 | 173 | static void print_help PARAMS ((void)); |
0b22d65c ZW |
174 | static void path_include PARAMS ((cpp_reader *, |
175 | struct cpp_pending *, | |
176 | char *, int)); | |
6de1e2a9 | 177 | static void initialize_builtins PARAMS ((cpp_reader *)); |
0b22d65c ZW |
178 | static void append_include_chain PARAMS ((cpp_reader *, |
179 | struct cpp_pending *, | |
c45da1ca | 180 | char *, int, int)); |
bcc5cac9 KG |
181 | static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *)); |
182 | static void initialize_dependency_output PARAMS ((cpp_reader *)); | |
c45da1ca | 183 | static void initialize_standard_includes PARAMS ((cpp_reader *)); |
40ea76de ZW |
184 | static void new_pending_define PARAMS ((struct cpp_options *, |
185 | const char *)); | |
6de1e2a9 | 186 | |
c45da1ca | 187 | /* Fourth argument to append_include_chain: chain to use */ |
0b22d65c | 188 | enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; |
6de1e2a9 | 189 | |
455d2586 ZW |
190 | /* If we have designated initializers (GCC >2.7, or C99) this table |
191 | can be initialized, constant data. Otherwise, it has to be filled | |
192 | in at runtime. */ | |
a9ae4483 | 193 | |
455d2586 ZW |
194 | #if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L) |
195 | #define init_IStable() /* nothing */ | |
196 | #define ISTABLE const unsigned char _cpp_IStable[256] = { | |
a9ae4483 | 197 | #define END }; |
455d2586 | 198 | #define s(p, v) [p] = v, |
a9ae4483 | 199 | #else |
455d2586 ZW |
200 | #define ISTABLE unsigned char _cpp_IStable[256] = { 0 }; \ |
201 | static void init_IStable PARAMS ((void)) { \ | |
c6491210 | 202 | unsigned char *x = _cpp_IStable; |
a9ae4483 | 203 | #define END } |
455d2586 | 204 | #define s(p, v) x[p] = v; |
a9ae4483 | 205 | #endif |
6de1e2a9 | 206 | |
a9ae4483 ZW |
207 | #define A(x) s(x, ISidnum|ISidstart) |
208 | #define N(x) s(x, ISidnum|ISnumstart) | |
209 | #define H(x) s(x, IShspace|ISspace) | |
210 | #define S(x) s(x, ISspace) | |
6de1e2a9 | 211 | |
455d2586 | 212 | ISTABLE |
a9ae4483 | 213 | A('_') |
6de1e2a9 | 214 | |
a9ae4483 ZW |
215 | A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i') |
216 | A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r') | |
217 | A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z') | |
6de1e2a9 | 218 | |
a9ae4483 ZW |
219 | A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I') |
220 | A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R') | |
221 | A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z') | |
6de1e2a9 | 222 | |
a9ae4483 | 223 | N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0') |
5538ada6 | 224 | |
a9ae4483 | 225 | H(' ') H('\t') H('\v') H('\f') |
6de1e2a9 | 226 | |
a9ae4483 ZW |
227 | S('\n') |
228 | END | |
229 | ||
230 | #undef A | |
231 | #undef N | |
232 | #undef H | |
233 | #undef S | |
a9ae4483 | 234 | #undef s |
455d2586 ZW |
235 | #undef ISTABLE |
236 | #undef END | |
6de1e2a9 ZW |
237 | |
238 | /* Given a colon-separated list of file names PATH, | |
239 | add all the names to the search path for include files. */ | |
240 | ||
241 | static void | |
0b22d65c | 242 | path_include (pfile, pend, list, path) |
6de1e2a9 | 243 | cpp_reader *pfile; |
0b22d65c ZW |
244 | struct cpp_pending *pend; |
245 | char *list; | |
246 | int path; | |
6de1e2a9 | 247 | { |
0b22d65c | 248 | char *p, *q, *name; |
6de1e2a9 | 249 | |
0b22d65c | 250 | p = list; |
6de1e2a9 | 251 | |
0b22d65c ZW |
252 | do |
253 | { | |
6de1e2a9 | 254 | /* Find the end of this name. */ |
0b22d65c | 255 | q = p; |
6de1e2a9 | 256 | while (*q != 0 && *q != PATH_SEPARATOR) q++; |
0b22d65c ZW |
257 | if (q == p) |
258 | { | |
259 | /* An empty name in the path stands for the current directory. */ | |
260 | name = (char *) xmalloc (2); | |
261 | name[0] = '.'; | |
262 | name[1] = 0; | |
263 | } | |
264 | else | |
265 | { | |
266 | /* Otherwise use the directory that is named. */ | |
267 | name = (char *) xmalloc (q - p + 1); | |
268 | memcpy (name, p, q - p); | |
269 | name[q - p] = 0; | |
270 | } | |
6de1e2a9 | 271 | |
c45da1ca | 272 | append_include_chain (pfile, pend, name, path, 0); |
6de1e2a9 ZW |
273 | |
274 | /* Advance past this name. */ | |
0b22d65c | 275 | if (*q == 0) |
6de1e2a9 | 276 | break; |
0b22d65c ZW |
277 | p = q + 1; |
278 | } | |
279 | while (1); | |
280 | } | |
281 | ||
0b22d65c ZW |
282 | /* Append DIR to include path PATH. DIR must be permanently allocated |
283 | and writable. */ | |
284 | static void | |
c45da1ca | 285 | append_include_chain (pfile, pend, dir, path, cxx_aware) |
0b22d65c ZW |
286 | cpp_reader *pfile; |
287 | struct cpp_pending *pend; | |
288 | char *dir; | |
289 | int path; | |
c45da1ca | 290 | int cxx_aware; |
0b22d65c ZW |
291 | { |
292 | struct file_name_list *new; | |
293 | struct stat st; | |
294 | unsigned int len; | |
295 | ||
296 | simplify_pathname (dir); | |
297 | if (stat (dir, &st)) | |
298 | { | |
299 | /* Dirs that don't exist are silently ignored. */ | |
300 | if (errno != ENOENT) | |
c1212d2f | 301 | cpp_notice_from_errno (pfile, dir); |
0b22d65c | 302 | else if (CPP_OPTIONS (pfile)->verbose) |
c1212d2f | 303 | fprintf (stderr, _("ignoring nonexistent directory `%s'\n"), dir); |
0b22d65c ZW |
304 | return; |
305 | } | |
306 | ||
307 | if (!S_ISDIR (st.st_mode)) | |
308 | { | |
c1212d2f | 309 | cpp_notice (pfile, "%s: Not a directory", dir); |
0b22d65c ZW |
310 | return; |
311 | } | |
312 | ||
313 | len = strlen (dir); | |
314 | if (len > pfile->max_include_len) | |
315 | pfile->max_include_len = len; | |
316 | ||
317 | new = (struct file_name_list *)xmalloc (sizeof (struct file_name_list)); | |
318 | new->name = dir; | |
319 | new->nlen = len; | |
320 | new->ino = st.st_ino; | |
321 | new->dev = st.st_dev; | |
c45da1ca ZW |
322 | if (path == SYSTEM) |
323 | new->sysp = cxx_aware ? 1 : 2; | |
324 | else | |
325 | new->sysp = 0; | |
0b22d65c | 326 | new->name_map = NULL; |
503cb436 DB |
327 | new->next = NULL; |
328 | new->alloc = NULL; | |
0b22d65c ZW |
329 | |
330 | switch (path) | |
331 | { | |
332 | case QUOTE: APPEND (pend, quote, new); break; | |
333 | case BRACKET: APPEND (pend, brack, new); break; | |
334 | case SYSTEM: APPEND (pend, systm, new); break; | |
335 | case AFTER: APPEND (pend, after, new); break; | |
6de1e2a9 ZW |
336 | } |
337 | } | |
338 | ||
0b22d65c | 339 | |
6de1e2a9 ZW |
340 | /* Write out a #define command for the special named MACRO_NAME |
341 | to PFILE's token_buffer. */ | |
342 | ||
343 | static void | |
344 | dump_special_to_buffer (pfile, macro_name) | |
345 | cpp_reader *pfile; | |
bcc5cac9 | 346 | const char *macro_name; |
6de1e2a9 | 347 | { |
c45da1ca | 348 | static const char define_directive[] = "#define "; |
6de1e2a9 | 349 | int macro_name_length = strlen (macro_name); |
80e9dcb4 | 350 | output_line_command (pfile, same_file); |
6de1e2a9 ZW |
351 | CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length); |
352 | CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1); | |
353 | CPP_PUTS_Q (pfile, macro_name, macro_name_length); | |
354 | CPP_PUTC_Q (pfile, ' '); | |
355 | cpp_expand_to_buffer (pfile, macro_name, macro_name_length); | |
356 | CPP_PUTC (pfile, '\n'); | |
357 | } | |
358 | ||
6de1e2a9 ZW |
359 | /* Initialize a cpp_options structure. */ |
360 | void | |
361 | cpp_options_init (opts) | |
362 | cpp_options *opts; | |
363 | { | |
0b22d65c | 364 | bzero ((char *) opts, sizeof (struct cpp_options)); |
6de1e2a9 ZW |
365 | |
366 | opts->dollars_in_ident = 1; | |
367 | opts->cplusplus_comments = 1; | |
368 | opts->warn_import = 1; | |
564ad5f4 | 369 | opts->discard_comments = 1; |
0b22d65c | 370 | |
ad85216e KG |
371 | opts->pending = |
372 | (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending)); | |
6de1e2a9 ZW |
373 | } |
374 | ||
375 | /* Initialize a cpp_reader structure. */ | |
376 | void | |
377 | cpp_reader_init (pfile) | |
378 | cpp_reader *pfile; | |
379 | { | |
380 | bzero ((char *) pfile, sizeof (cpp_reader)); | |
6de1e2a9 ZW |
381 | |
382 | pfile->token_buffer_size = 200; | |
383 | pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size); | |
384 | CPP_SET_WRITTEN (pfile, 0); | |
122ae89b ZW |
385 | |
386 | pfile->hashtab = (HASHNODE **) xcalloc (HASHSIZE, sizeof (HASHNODE *)); | |
6de1e2a9 ZW |
387 | } |
388 | ||
389 | /* Free resources used by PFILE. | |
390 | This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology). */ | |
391 | void | |
392 | cpp_cleanup (pfile) | |
393 | cpp_reader *pfile; | |
394 | { | |
395 | int i; | |
396 | while (CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile)) | |
397 | cpp_pop_buffer (pfile); | |
398 | ||
399 | if (pfile->token_buffer) | |
400 | { | |
401 | free (pfile->token_buffer); | |
402 | pfile->token_buffer = NULL; | |
403 | } | |
404 | ||
2c826217 ZW |
405 | if (pfile->input_buffer) |
406 | { | |
407 | free (pfile->input_buffer); | |
408 | free (pfile->input_speccase); | |
409 | pfile->input_buffer = pfile->input_speccase = NULL; | |
410 | pfile->input_buffer_len = 0; | |
411 | } | |
412 | ||
49e6c08e ZW |
413 | if (pfile->deps) |
414 | deps_free (pfile->deps); | |
415 | ||
6de1e2a9 ZW |
416 | while (pfile->if_stack) |
417 | { | |
418 | IF_STACK_FRAME *temp = pfile->if_stack; | |
419 | pfile->if_stack = temp->next; | |
420 | free (temp); | |
421 | } | |
422 | ||
423 | for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; ) | |
424 | { | |
425 | struct include_hash *imp = pfile->all_include_files[i]; | |
426 | while (imp) | |
427 | { | |
428 | struct include_hash *next = imp->next; | |
49e6c08e ZW |
429 | |
430 | free ((PTR) imp->name); | |
6de1e2a9 ZW |
431 | free (imp); |
432 | imp = next; | |
433 | } | |
434 | pfile->all_include_files[i] = 0; | |
435 | } | |
436 | ||
122ae89b ZW |
437 | for (i = HASHSIZE; --i >= 0;) |
438 | { | |
439 | while (pfile->hashtab[i]) | |
440 | delete_macro (pfile->hashtab[i]); | |
441 | } | |
442 | free (pfile->hashtab); | |
6de1e2a9 ZW |
443 | } |
444 | ||
445 | ||
a9ae4483 ZW |
446 | /* This structure defines one built-in macro. A node of type TYPE will |
447 | be entered in the macro hash table under the name NAME, with value | |
448 | VALUE (if any). FLAGS tweaks the behavior a little: | |
449 | DUMP write debug info for this macro | |
450 | STDC define only if not -traditional | |
a9ae4483 ZW |
451 | ULP value is the global user_label_prefix (which can't be |
452 | put directly into the table). | |
453 | */ | |
454 | ||
455 | struct builtin | |
456 | { | |
457 | const char *name; | |
458 | const char *value; | |
459 | unsigned short type; | |
460 | unsigned short flags; | |
461 | }; | |
462 | #define DUMP 0x01 | |
463 | #define STDC 0x02 | |
a9ae4483 ZW |
464 | #define ULP 0x10 |
465 | ||
466 | static const struct builtin builtin_array[] = | |
6de1e2a9 | 467 | { |
a9ae4483 ZW |
468 | { "__TIME__", 0, T_TIME, DUMP }, |
469 | { "__DATE__", 0, T_DATE, DUMP }, | |
470 | { "__FILE__", 0, T_FILE, 0 }, | |
c45da1ca | 471 | { "__BASE_FILE__", 0, T_BASE_FILE, 0 }, |
a9ae4483 ZW |
472 | { "__LINE__", 0, T_SPECLINE, 0 }, |
473 | { "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL, 0 }, | |
474 | { "__VERSION__", 0, T_VERSION, DUMP }, | |
475 | { "__STDC__", 0, T_STDC, DUMP|STDC }, | |
476 | ||
477 | { "__USER_LABEL_PREFIX__", 0, T_CONST, ULP }, | |
478 | { "__REGISTER_PREFIX__", REGISTER_PREFIX, T_CONST, 0 }, | |
479 | { "__HAVE_BUILTIN_SETJMP__", "1", T_CONST, 0 }, | |
6de1e2a9 | 480 | #ifndef NO_BUILTIN_SIZE_TYPE |
a9ae4483 | 481 | { "__SIZE_TYPE__", SIZE_TYPE, T_CONST, DUMP }, |
6de1e2a9 ZW |
482 | #endif |
483 | #ifndef NO_BUILTIN_PTRDIFF_TYPE | |
a9ae4483 | 484 | { "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP }, |
6de1e2a9 | 485 | #endif |
0209c340 | 486 | #ifndef NO_BUILTIN_WCHAR_TYPE |
a9ae4483 | 487 | { "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP }, |
0209c340 | 488 | #endif |
a9ae4483 ZW |
489 | { 0, 0, 0, 0 } |
490 | }; | |
491 | ||
492 | /* Subroutine of cpp_start_read; reads the builtins table above and | |
493 | enters the macros into the hash table. */ | |
6de1e2a9 | 494 | |
a9ae4483 ZW |
495 | static void |
496 | initialize_builtins (pfile) | |
497 | cpp_reader *pfile; | |
498 | { | |
499 | int len; | |
500 | const struct builtin *b; | |
501 | const char *val; | |
502 | for(b = builtin_array; b->name; b++) | |
6de1e2a9 | 503 | { |
a9ae4483 ZW |
504 | if ((b->flags & STDC) && CPP_TRADITIONAL (pfile)) |
505 | continue; | |
a9ae4483 ZW |
506 | |
507 | val = (b->flags & ULP) ? user_label_prefix : b->value; | |
508 | len = strlen (b->name); | |
509 | ||
bb52fa7f | 510 | cpp_install (pfile, b->name, len, b->type, val); |
a9ae4483 ZW |
511 | if ((b->flags & DUMP) && CPP_OPTIONS (pfile)->debug_output) |
512 | dump_special_to_buffer (pfile, b->name); | |
6de1e2a9 | 513 | } |
a9ae4483 | 514 | |
6de1e2a9 | 515 | } |
a9ae4483 ZW |
516 | #undef DUMP |
517 | #undef STDC | |
a9ae4483 | 518 | #undef ULP |
6de1e2a9 | 519 | |
0b22d65c ZW |
520 | /* Another subroutine of cpp_start_read. This one sets up to do |
521 | dependency-file output. */ | |
522 | static void | |
523 | initialize_dependency_output (pfile) | |
524 | cpp_reader *pfile; | |
525 | { | |
526 | cpp_options *opts = CPP_OPTIONS (pfile); | |
527 | char *spec, *s, *output_file; | |
528 | ||
529 | /* Either of two environment variables can specify output of deps. | |
530 | Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET", | |
531 | where OUTPUT_FILE is the file to write deps info to | |
532 | and DEPS_TARGET is the target to mention in the deps. */ | |
533 | ||
534 | if (opts->print_deps == 0) | |
535 | { | |
536 | spec = getenv ("DEPENDENCIES_OUTPUT"); | |
537 | if (spec) | |
538 | opts->print_deps = 1; | |
539 | else | |
540 | { | |
541 | spec = getenv ("SUNPRO_DEPENDENCIES"); | |
542 | if (spec) | |
543 | opts->print_deps = 2; | |
544 | else | |
545 | return; | |
546 | } | |
547 | ||
548 | /* Find the space before the DEPS_TARGET, if there is one. */ | |
549 | s = strchr (spec, ' '); | |
550 | if (s) | |
551 | { | |
552 | opts->deps_target = s + 1; | |
553 | output_file = (char *) xmalloc (s - spec + 1); | |
554 | memcpy (output_file, spec, s - spec); | |
555 | output_file[s - spec] = 0; | |
556 | } | |
557 | else | |
558 | { | |
559 | opts->deps_target = 0; | |
560 | output_file = spec; | |
561 | } | |
562 | ||
563 | opts->deps_file = output_file; | |
564 | opts->print_deps_append = 1; | |
565 | } | |
566 | ||
49e6c08e | 567 | pfile->deps = deps_init (); |
0b22d65c | 568 | |
49e6c08e | 569 | /* Print the expected object file name as the target of this Make-rule. */ |
0b22d65c | 570 | if (opts->deps_target) |
49e6c08e | 571 | deps_add_target (pfile->deps, opts->deps_target); |
0b22d65c | 572 | else if (*opts->in_fname == 0) |
49e6c08e | 573 | deps_add_target (pfile->deps, "-"); |
0b22d65c | 574 | else |
49e6c08e | 575 | deps_calc_target (pfile->deps, opts->in_fname); |
0b22d65c | 576 | |
49e6c08e ZW |
577 | if (opts->in_fname) |
578 | deps_add_dep (pfile->deps, opts->in_fname); | |
0b22d65c ZW |
579 | } |
580 | ||
c45da1ca ZW |
581 | /* And another subroutine. This one sets up the standard include path. */ |
582 | static void | |
583 | initialize_standard_includes (pfile) | |
584 | cpp_reader *pfile; | |
585 | { | |
586 | cpp_options *opts = CPP_OPTIONS (pfile); | |
587 | char *path; | |
455d2586 | 588 | const struct default_include *p; |
c45da1ca ZW |
589 | char *specd_prefix = opts->include_prefix; |
590 | ||
591 | /* Several environment variables may add to the include search path. | |
592 | CPATH specifies an additional list of directories to be searched | |
593 | as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, | |
594 | etc. specify an additional list of directories to be searched as | |
595 | if specified with -isystem, for the language indicated. */ | |
596 | ||
597 | GET_ENV_PATH_LIST (path, "CPATH"); | |
598 | if (path != 0 && *path != 0) | |
599 | path_include (pfile, opts->pending, path, BRACKET); | |
600 | ||
601 | switch ((opts->objc << 1) + opts->cplusplus) | |
602 | { | |
603 | case 0: | |
604 | GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH"); | |
605 | break; | |
606 | case 1: | |
607 | GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH"); | |
608 | break; | |
609 | case 2: | |
610 | GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH"); | |
611 | break; | |
612 | case 3: | |
613 | GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH"); | |
614 | break; | |
615 | } | |
616 | if (path != 0 && *path != 0) | |
617 | path_include (pfile, opts->pending, path, SYSTEM); | |
618 | ||
619 | /* Search "translated" versions of GNU directories. | |
620 | These have /usr/local/lib/gcc... replaced by specd_prefix. */ | |
621 | if (specd_prefix != 0) | |
622 | { | |
623 | char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7); | |
624 | /* Remove the `include' from /usr/local/lib/gcc.../include. | |
625 | GCC_INCLUDE_DIR will always end in /include. */ | |
626 | int default_len = sizeof GCC_INCLUDE_DIR - 8; | |
627 | int specd_len = strlen (specd_prefix); | |
628 | ||
629 | memcpy (default_prefix, GCC_INCLUDE_DIR, default_len); | |
630 | default_prefix[default_len] = '\0'; | |
631 | ||
632 | for (p = include_defaults_array; p->fname; p++) | |
633 | { | |
634 | /* Some standard dirs are only for C++. */ | |
635 | if (!p->cplusplus | |
636 | || (opts->cplusplus | |
637 | && !opts->no_standard_cplusplus_includes)) | |
638 | { | |
639 | /* Does this dir start with the prefix? */ | |
640 | if (!strncmp (p->fname, default_prefix, default_len)) | |
641 | { | |
642 | /* Yes; change prefix and add to search list. */ | |
643 | int flen = strlen (p->fname); | |
644 | int this_len = specd_len + flen - default_len; | |
645 | char *str = (char *) xmalloc (this_len + 1); | |
646 | memcpy (str, specd_prefix, specd_len); | |
647 | memcpy (str + specd_len, | |
648 | p->fname + default_len, | |
649 | flen - default_len + 1); | |
650 | ||
651 | append_include_chain (pfile, opts->pending, | |
652 | str, SYSTEM, p->cxx_aware); | |
653 | } | |
654 | } | |
655 | } | |
656 | } | |
657 | ||
658 | /* Search ordinary names for GNU include directories. */ | |
659 | for (p = include_defaults_array; p->fname; p++) | |
660 | { | |
661 | /* Some standard dirs are only for C++. */ | |
662 | if (!p->cplusplus | |
663 | || (opts->cplusplus | |
664 | && !opts->no_standard_cplusplus_includes)) | |
665 | { | |
666 | /* XXX Potential memory leak! */ | |
667 | char *str = xstrdup (update_path (p->fname, p->component)); | |
668 | append_include_chain (pfile, opts->pending, str, SYSTEM, | |
669 | p->cxx_aware); | |
670 | } | |
671 | } | |
672 | } | |
673 | ||
6de1e2a9 ZW |
674 | /* This is called after options have been processed. |
675 | * Check options for consistency, and setup for processing input | |
676 | * from the file named FNAME. (Use standard input if FNAME==NULL.) | |
677 | * Return 1 on success, 0 on failure. | |
678 | */ | |
679 | ||
680 | int | |
681 | cpp_start_read (pfile, fname) | |
682 | cpp_reader *pfile; | |
683 | char *fname; | |
684 | { | |
685 | struct cpp_options *opts = CPP_OPTIONS (pfile); | |
0b22d65c | 686 | struct pending_option *p, *q; |
6de1e2a9 | 687 | |
0b22d65c ZW |
688 | /* -MG doesn't select the form of output and must be specified with one of |
689 | -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't | |
690 | inhibit compilation. */ | |
691 | if (opts->print_deps_missing_files | |
692 | && (opts->print_deps == 0 || !opts->no_output)) | |
693 | { | |
694 | cpp_fatal (pfile, "-MG must be specified with one of -M or -MM"); | |
695 | return 0; | |
696 | } | |
6de1e2a9 | 697 | |
0b22d65c ZW |
698 | /* Chill should not be used with -trigraphs. */ |
699 | if (opts->chill && opts->trigraphs) | |
700 | { | |
701 | cpp_warning (pfile, "-lang-chill and -trigraphs are mutually exclusive"); | |
702 | opts->trigraphs = 0; | |
703 | } | |
704 | ||
705 | /* Set this if it hasn't been set already. */ | |
706 | if (user_label_prefix == NULL) | |
707 | user_label_prefix = USER_LABEL_PREFIX; | |
c45da1ca ZW |
708 | |
709 | /* Don't bother trying to do macro expansion if we've already done | |
710 | preprocessing. */ | |
711 | if (opts->preprocessed) | |
712 | pfile->no_macro_expand++; | |
455d2586 ZW |
713 | |
714 | /* Set up the IStable. This doesn't do anything if we were compiled | |
715 | with a compiler that supports C99 designated initializers. */ | |
a9ae4483 | 716 | init_IStable (); |
6de1e2a9 | 717 | |
c45da1ca ZW |
718 | /* Set up the include search path now. */ |
719 | if (! opts->no_standard_includes) | |
720 | initialize_standard_includes (pfile); | |
721 | ||
722 | merge_include_chains (opts); | |
723 | ||
724 | /* With -v, print the list of dirs to search. */ | |
725 | if (opts->verbose) | |
726 | { | |
727 | struct file_name_list *l; | |
728 | fprintf (stderr, _("#include \"...\" search starts here:\n")); | |
729 | for (l = opts->quote_include; l; l = l->next) | |
730 | { | |
731 | if (l == opts->bracket_include) | |
732 | fprintf (stderr, _("#include <...> search starts here:\n")); | |
733 | fprintf (stderr, " %s\n", l->name); | |
734 | } | |
735 | fprintf (stderr, _("End of search list.\n")); | |
736 | } | |
737 | ||
738 | initialize_dependency_output (pfile); | |
739 | ||
740 | /* Open the main input file. This must be done before -D processing | |
741 | so we have a buffer to stand on. */ | |
6de1e2a9 ZW |
742 | if (opts->in_fname == NULL || *opts->in_fname == 0) |
743 | { | |
744 | opts->in_fname = fname; | |
745 | if (opts->in_fname == NULL) | |
746 | opts->in_fname = ""; | |
747 | } | |
6de1e2a9 | 748 | |
c45da1ca ZW |
749 | if (!cpp_read_file (pfile, fname)) |
750 | return 0; | |
751 | ||
752 | /* -D and friends may produce output, which should be identified | |
753 | as line 0. */ | |
754 | ||
755 | CPP_BUFFER (pfile)->lineno = 0; | |
756 | ||
757 | /* Install __LINE__, etc. */ | |
6de1e2a9 ZW |
758 | initialize_builtins (pfile); |
759 | ||
6de1e2a9 | 760 | /* Do -U's, -D's and -A's in the order they were seen. */ |
0b22d65c ZW |
761 | p = opts->pending->define_head; |
762 | while (p) | |
6de1e2a9 | 763 | { |
0b22d65c ZW |
764 | if (p->undef) |
765 | cpp_undef (pfile, p->arg); | |
766 | else | |
767 | cpp_define (pfile, p->arg); | |
6de1e2a9 | 768 | |
0b22d65c ZW |
769 | q = p->next; |
770 | free (p); | |
771 | p = q; | |
6de1e2a9 | 772 | } |
6de1e2a9 | 773 | |
0b22d65c ZW |
774 | p = opts->pending->assert_head; |
775 | while (p) | |
6de1e2a9 | 776 | { |
0b22d65c ZW |
777 | if (p->undef) |
778 | cpp_unassert (pfile, p->arg); | |
779 | else | |
780 | cpp_assert (pfile, p->arg); | |
6de1e2a9 | 781 | |
0b22d65c ZW |
782 | q = p->next; |
783 | free (p); | |
784 | p = q; | |
785 | } | |
786 | ||
787 | opts->done_initializing = 1; | |
c45da1ca | 788 | CPP_BUFFER (pfile)->lineno = 1; |
6de1e2a9 | 789 | |
3773a46b JM |
790 | if (opts->preprocessed) |
791 | /* If we've already processed this code, we want to trust the #line | |
792 | directives in the input. But we still need to update our line | |
793 | counter accordingly. */ | |
794 | pfile->lineno = CPP_BUFFER (pfile)->lineno; | |
795 | else | |
796 | output_line_command (pfile, same_file); | |
6de1e2a9 ZW |
797 | pfile->only_seen_white = 2; |
798 | ||
799 | /* The -imacros files can be scanned now, but the -include files | |
800 | have to be pushed onto the include stack and processed later, | |
0b22d65c | 801 | in the main loop calling cpp_get_token. */ |
6de1e2a9 | 802 | |
6de1e2a9 | 803 | opts->no_output++; |
0b22d65c ZW |
804 | p = opts->pending->imacros_head; |
805 | while (p) | |
6de1e2a9 | 806 | { |
c45da1ca ZW |
807 | if (cpp_read_file (pfile, p->arg)) |
808 | cpp_scan_buffer (pfile); | |
0b22d65c ZW |
809 | |
810 | q = p->next; | |
811 | free (p); | |
812 | p = q; | |
6de1e2a9 ZW |
813 | } |
814 | opts->no_output--; | |
0b22d65c ZW |
815 | |
816 | p = opts->pending->include_head; | |
817 | while (p) | |
6de1e2a9 | 818 | { |
c45da1ca ZW |
819 | if (cpp_read_file (pfile, p->arg)) |
820 | output_line_command (pfile, enter_file); | |
821 | ||
0b22d65c ZW |
822 | q = p->next; |
823 | free (p); | |
824 | p = q; | |
6de1e2a9 | 825 | } |
6de1e2a9 | 826 | |
0b22d65c | 827 | free (opts->pending); |
6de1e2a9 ZW |
828 | opts->pending = NULL; |
829 | ||
830 | return 1; | |
831 | } | |
832 | ||
833 | /* This is called at the end of preprocessing. It pops the | |
834 | last buffer and writes dependency output. It should also | |
835 | clear macro definitions, such that you could call cpp_start_read | |
836 | with a new filename to restart processing. */ | |
837 | void | |
838 | cpp_finish (pfile) | |
839 | cpp_reader *pfile; | |
840 | { | |
841 | struct cpp_options *opts = CPP_OPTIONS (pfile); | |
842 | ||
843 | if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != CPP_NULL_BUFFER (pfile)) | |
c1212d2f | 844 | cpp_ice (pfile, "buffers still stacked in cpp_finish"); |
6de1e2a9 | 845 | cpp_pop_buffer (pfile); |
c1212d2f | 846 | |
49e6c08e ZW |
847 | /* Don't write the deps file if preprocessing has failed. */ |
848 | if (opts->print_deps && pfile->errors == 0) | |
6de1e2a9 ZW |
849 | { |
850 | /* Stream on which to print the dependency information. */ | |
c1212d2f | 851 | FILE *deps_stream = 0; |
6de1e2a9 | 852 | |
49e6c08e ZW |
853 | const char *deps_mode = opts->print_deps_append ? "a" : "w"; |
854 | if (opts->deps_file == 0) | |
855 | deps_stream = stdout; | |
856 | else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0) | |
857 | cpp_notice_from_errno (pfile, opts->deps_file); | |
c1212d2f | 858 | |
49e6c08e ZW |
859 | if (deps_stream) |
860 | { | |
861 | deps_write (pfile->deps, deps_stream, 72); | |
862 | if (opts->deps_file) | |
6de1e2a9 | 863 | { |
49e6c08e ZW |
864 | if (ferror (deps_stream) || fclose (deps_stream) != 0) |
865 | cpp_fatal (pfile, "I/O error on output"); | |
6de1e2a9 ZW |
866 | } |
867 | } | |
868 | } | |
3caee4a8 ZW |
869 | |
870 | if (opts->dump_macros == dump_only) | |
871 | { | |
872 | int i; | |
873 | HASHNODE *h; | |
3caee4a8 ZW |
874 | for (i = HASHSIZE; --i >= 0;) |
875 | { | |
876 | for (h = pfile->hashtab[i]; h; h = h->next) | |
877 | if (h->type == T_MACRO) | |
878 | { | |
a2a76ce7 | 879 | dump_definition (pfile, h->name, h->length, h->value.defn); |
3caee4a8 ZW |
880 | CPP_PUTC (pfile, '\n'); |
881 | } | |
882 | } | |
883 | } | |
6de1e2a9 ZW |
884 | } |
885 | ||
223dca6a RH |
886 | static void |
887 | new_pending_define (opts, text) | |
888 | struct cpp_options *opts; | |
889 | const char *text; | |
890 | { | |
891 | struct pending_option *o = (struct pending_option *) | |
892 | xmalloc (sizeof (struct pending_option)); | |
893 | ||
c8d8ed65 | 894 | o->arg = (char *) text; |
223dca6a RH |
895 | o->next = NULL; |
896 | o->undef = 0; | |
897 | APPEND (opts->pending, define, o); | |
898 | } | |
899 | ||
6de1e2a9 ZW |
900 | /* Handle one command-line option in (argc, argv). |
901 | Can be called multiple times, to handle multiple sets of options. | |
902 | Returns number of strings consumed. */ | |
c8d8ed65 | 903 | |
6de1e2a9 ZW |
904 | int |
905 | cpp_handle_option (pfile, argc, argv) | |
906 | cpp_reader *pfile; | |
907 | int argc; | |
908 | char **argv; | |
909 | { | |
910 | struct cpp_options *opts = CPP_OPTIONS (pfile); | |
911 | int i = 0; | |
912 | ||
0b22d65c ZW |
913 | if (argv[i][0] != '-') |
914 | { | |
915 | if (opts->out_fname != NULL) | |
6de1e2a9 | 916 | { |
0b22d65c ZW |
917 | print_help (); |
918 | cpp_fatal (pfile, "Too many arguments"); | |
6de1e2a9 | 919 | } |
0b22d65c ZW |
920 | else if (opts->in_fname != NULL) |
921 | opts->out_fname = argv[i]; | |
922 | else | |
923 | opts->in_fname = argv[i]; | |
924 | } | |
925 | else | |
926 | switch (argv[i][1]) | |
927 | { | |
928 | case 'f': | |
929 | if (!strcmp (argv[i], "-fleading-underscore")) | |
930 | user_label_prefix = "_"; | |
931 | else if (!strcmp (argv[i], "-fno-leading-underscore")) | |
932 | user_label_prefix = ""; | |
3773a46b JM |
933 | else if (!strcmp (argv[i], "-fpreprocessed")) |
934 | opts->preprocessed = 1; | |
935 | else if (!strcmp (argv[i], "-fno-preprocessed")) | |
936 | opts->preprocessed = 0; | |
bb51178f NC |
937 | else |
938 | { | |
939 | return i; | |
940 | } | |
0b22d65c ZW |
941 | break; |
942 | ||
943 | case 'I': /* Add directory to path for includes. */ | |
944 | if (!strcmp (argv[i] + 2, "-")) | |
945 | { | |
946 | /* -I- means: | |
947 | Use the preceding -I directories for #include "..." | |
948 | but not #include <...>. | |
949 | Don't search the directory of the present file | |
950 | for #include "...". (Note that -I. -I- is not the same as | |
951 | the default setup; -I. uses the compiler's working dir.) */ | |
952 | if (! opts->ignore_srcdir) | |
953 | { | |
954 | opts->ignore_srcdir = 1; | |
955 | opts->pending->quote_head = opts->pending->brack_head; | |
956 | opts->pending->quote_tail = opts->pending->brack_tail; | |
957 | opts->pending->brack_head = 0; | |
958 | opts->pending->brack_tail = 0; | |
959 | } | |
960 | else | |
961 | { | |
962 | cpp_fatal (pfile, "-I- specified twice"); | |
963 | return argc; | |
964 | } | |
965 | } | |
966 | else | |
967 | { | |
968 | char *fname; | |
969 | if (argv[i][2] != 0) | |
970 | fname = argv[i] + 2; | |
971 | else if (i + 1 == argc) | |
972 | goto missing_dirname; | |
973 | else | |
974 | fname = argv[++i]; | |
975 | append_include_chain (pfile, opts->pending, | |
c45da1ca | 976 | xstrdup (fname), BRACKET, 0); |
0b22d65c ZW |
977 | } |
978 | break; | |
979 | ||
980 | case 'i': | |
981 | /* Add directory to beginning of system include path, as a system | |
982 | include directory. */ | |
983 | if (!strcmp (argv[i], "-isystem")) | |
984 | { | |
985 | if (i + 1 == argc) | |
986 | goto missing_filename; | |
987 | append_include_chain (pfile, opts->pending, | |
c45da1ca | 988 | xstrdup (argv[++i]), SYSTEM, 0); |
0b22d65c ZW |
989 | } |
990 | else if (!strcmp (argv[i], "-include")) | |
991 | { | |
992 | if (i + 1 == argc) | |
993 | goto missing_filename; | |
994 | else | |
995 | { | |
996 | struct pending_option *o = (struct pending_option *) | |
997 | xmalloc (sizeof (struct pending_option)); | |
998 | o->arg = argv[++i]; | |
999 | ||
1000 | /* This list has to be built in reverse order so that | |
1001 | when cpp_start_read pushes all the -include files onto | |
1002 | the buffer stack, they will be scanned in forward order. */ | |
1003 | o->next = opts->pending->include_head; | |
1004 | opts->pending->include_head = o; | |
1005 | } | |
1006 | } | |
1007 | else if (!strcmp (argv[i], "-imacros")) | |
1008 | { | |
1009 | if (i + 1 == argc) | |
1010 | goto missing_filename; | |
1011 | else | |
1012 | { | |
1013 | struct pending_option *o = (struct pending_option *) | |
1014 | xmalloc (sizeof (struct pending_option)); | |
1015 | o->arg = argv[++i]; | |
1016 | o->next = NULL; | |
1017 | ||
1018 | APPEND (opts->pending, imacros, o); | |
1019 | } | |
1020 | } | |
1021 | /* Add directory to end of path for includes, | |
1022 | with the default prefix at the front of its name. */ | |
1023 | else if (!strcmp (argv[i], "-iwithprefix")) | |
1024 | { | |
1025 | char *fname; | |
1026 | int len; | |
1027 | if (i + 1 == argc) | |
1028 | goto missing_dirname; | |
1029 | ++i; | |
1030 | len = strlen (argv[i]); | |
1031 | ||
1032 | if (opts->include_prefix != 0) | |
1033 | { | |
1034 | fname = xmalloc (opts->include_prefix_len + len + 1); | |
1035 | memcpy (fname, opts->include_prefix, opts->include_prefix_len); | |
1036 | memcpy (fname + opts->include_prefix_len, argv[i], len + 1); | |
1037 | } | |
1038 | else | |
1039 | { | |
1040 | fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len); | |
1041 | memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9); | |
1042 | memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1); | |
1043 | } | |
6de1e2a9 | 1044 | |
c45da1ca | 1045 | append_include_chain (pfile, opts->pending, fname, SYSTEM, 0); |
0b22d65c ZW |
1046 | } |
1047 | /* Add directory to main path for includes, | |
1048 | with the default prefix at the front of its name. */ | |
1049 | else if (!strcmp (argv[i], "-iwithprefixbefore")) | |
1050 | { | |
1051 | char *fname; | |
1052 | int len; | |
1053 | if (i + 1 == argc) | |
1054 | goto missing_dirname; | |
1055 | ++i; | |
1056 | len = strlen (argv[i]); | |
1057 | ||
1058 | if (opts->include_prefix != 0) | |
1059 | { | |
1060 | fname = xmalloc (opts->include_prefix_len + len + 1); | |
1061 | memcpy (fname, opts->include_prefix, opts->include_prefix_len); | |
1062 | memcpy (fname + opts->include_prefix_len, argv[i], len + 1); | |
1063 | } | |
1064 | else | |
1065 | { | |
1066 | fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len); | |
1067 | memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9); | |
1068 | memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1); | |
1069 | } | |
6de1e2a9 | 1070 | |
c45da1ca | 1071 | append_include_chain (pfile, opts->pending, fname, BRACKET, 0); |
0b22d65c ZW |
1072 | } |
1073 | /* Add directory to end of path for includes. */ | |
1074 | else if (!strcmp (argv[i], "-idirafter")) | |
1075 | { | |
1076 | if (i + 1 == argc) | |
1077 | goto missing_dirname; | |
1078 | append_include_chain (pfile, opts->pending, | |
c45da1ca | 1079 | xstrdup (argv[++i]), AFTER, 0); |
0b22d65c ZW |
1080 | } |
1081 | else if (!strcmp (argv[i], "-iprefix")) | |
1082 | { | |
1083 | if (i + 1 == argc) | |
1084 | goto missing_filename; | |
1085 | else | |
1086 | { | |
1087 | opts->include_prefix = argv[++i]; | |
1088 | opts->include_prefix_len = strlen (argv[i]); | |
1089 | } | |
1090 | } | |
0b22d65c | 1091 | break; |
6de1e2a9 | 1092 | |
0b22d65c ZW |
1093 | case 'o': |
1094 | if (opts->out_fname != NULL) | |
1095 | { | |
1096 | cpp_fatal (pfile, "Output filename specified twice"); | |
1097 | return argc; | |
1098 | } | |
1099 | if (i + 1 == argc) | |
1100 | goto missing_filename; | |
1101 | opts->out_fname = argv[++i]; | |
1102 | if (!strcmp (opts->out_fname, "-")) | |
1103 | opts->out_fname = ""; | |
1104 | break; | |
6de1e2a9 | 1105 | |
0b22d65c ZW |
1106 | case 'p': |
1107 | if (!strcmp (argv[i], "-pedantic")) | |
49634cde | 1108 | opts->pedantic = 1; |
0b22d65c ZW |
1109 | else if (!strcmp (argv[i], "-pedantic-errors")) |
1110 | { | |
49634cde | 1111 | opts->pedantic = 1; |
0b22d65c ZW |
1112 | opts->pedantic_errors = 1; |
1113 | } | |
0b22d65c | 1114 | break; |
6de1e2a9 | 1115 | |
0b22d65c ZW |
1116 | case 't': |
1117 | if (!strcmp (argv[i], "-traditional")) | |
1118 | { | |
1119 | opts->traditional = 1; | |
1120 | opts->cplusplus_comments = 0; | |
40c79d58 ZW |
1121 | opts->trigraphs = 0; |
1122 | opts->warn_trigraphs = 0; | |
0b22d65c ZW |
1123 | } |
1124 | else if (!strcmp (argv[i], "-trigraphs")) | |
6de1e2a9 | 1125 | opts->trigraphs = 1; |
0b22d65c | 1126 | break; |
6de1e2a9 | 1127 | |
0b22d65c ZW |
1128 | case 'l': |
1129 | if (! strcmp (argv[i], "-lang-c")) | |
1130 | opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0, | |
916269ab | 1131 | opts->c99 = 1, opts->objc = 0; |
0b22d65c | 1132 | if (! strcmp (argv[i], "-lang-c89")) |
223dca6a RH |
1133 | { |
1134 | opts->cplusplus = 0, opts->cplusplus_comments = 0; | |
916269ab | 1135 | opts->c89 = 1, opts->c99 = 0, opts->objc = 0; |
223dca6a | 1136 | opts->trigraphs = 1; |
e05eb761 | 1137 | new_pending_define (opts, "__STRICT_ANSI__"); |
223dca6a | 1138 | } |
0b22d65c ZW |
1139 | if (! strcmp (argv[i], "-lang-c++")) |
1140 | opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0, | |
916269ab | 1141 | opts->c99 = 0, opts->objc = 0; |
0b22d65c ZW |
1142 | if (! strcmp (argv[i], "-lang-objc")) |
1143 | opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0, | |
916269ab | 1144 | opts->c99 = 0, opts->objc = 1; |
0b22d65c ZW |
1145 | if (! strcmp (argv[i], "-lang-objc++")) |
1146 | opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0, | |
916269ab | 1147 | opts->c99 = 0, opts->objc = 1; |
0b22d65c ZW |
1148 | if (! strcmp (argv[i], "-lang-asm")) |
1149 | opts->lang_asm = 1; | |
40c79d58 ZW |
1150 | if (! strcmp (argv[i], "-lang-fortran")) |
1151 | opts->lang_fortran = 1, opts->cplusplus_comments = 0; | |
0b22d65c ZW |
1152 | if (! strcmp (argv[i], "-lang-chill")) |
1153 | opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, | |
1154 | opts->traditional = 1; | |
1155 | break; | |
6de1e2a9 | 1156 | |
0b22d65c ZW |
1157 | case '+': |
1158 | opts->cplusplus = 1, opts->cplusplus_comments = 1; | |
1159 | break; | |
1160 | ||
1161 | case 's': | |
223dca6a RH |
1162 | if (!strcmp (argv[i], "-std=gnu89")) |
1163 | { | |
75ec21db | 1164 | opts->cplusplus = 0, opts->cplusplus_comments = 1; |
916269ab | 1165 | opts->c89 = 1, opts->c99 = 0, opts->objc = 0; |
223dca6a | 1166 | } |
916269ab UD |
1167 | else if (!strcmp (argv[i], "-std=gnu9x") |
1168 | || !strcmp (argv[i], "-std=gnu99")) | |
223dca6a RH |
1169 | { |
1170 | opts->cplusplus = 0, opts->cplusplus_comments = 1; | |
916269ab | 1171 | opts->c89 = 0, opts->c99 = 1, opts->objc = 0; |
e05eb761 | 1172 | new_pending_define (opts, "__STDC_VERSION__=199901L"); |
223dca6a RH |
1173 | } |
1174 | else if (!strcmp (argv[i], "-std=iso9899:1990") | |
1175 | || !strcmp (argv[i], "-std=c89")) | |
1176 | { | |
1177 | opts->cplusplus = 0, opts->cplusplus_comments = 0; | |
916269ab | 1178 | opts->c89 = 1, opts->c99 = 0, opts->objc = 0; |
223dca6a | 1179 | opts->trigraphs = 1; |
e05eb761 | 1180 | new_pending_define (opts, "__STRICT_ANSI__"); |
223dca6a RH |
1181 | } |
1182 | else if (!strcmp (argv[i], "-std=iso9899:199409")) | |
1183 | { | |
1184 | opts->cplusplus = 0, opts->cplusplus_comments = 0; | |
916269ab | 1185 | opts->c89 = 1, opts->c99 = 0, opts->objc = 0; |
223dca6a | 1186 | opts->trigraphs = 1; |
e05eb761 RH |
1187 | new_pending_define (opts, "__STRICT_ANSI__"); |
1188 | new_pending_define (opts, "__STDC_VERSION__=199409L"); | |
223dca6a | 1189 | } |
0b22d65c | 1190 | else if (!strcmp (argv[i], "-std=iso9899:199x") |
223dca6a | 1191 | || !strcmp (argv[i], "-std=iso9899:1999") |
0b22d65c | 1192 | || !strcmp (argv[i], "-std=c9x") |
223dca6a RH |
1193 | || !strcmp (argv[i], "-std=c99")) |
1194 | { | |
1195 | opts->cplusplus = 0, opts->cplusplus_comments = 1; | |
916269ab | 1196 | opts->c89 = 0, opts->c99 = 1, opts->objc = 0; |
223dca6a | 1197 | opts->trigraphs = 1; |
e05eb761 RH |
1198 | new_pending_define (opts, "__STRICT_ANSI__"); |
1199 | new_pending_define (opts, "__STDC_VERSION__=199901L"); | |
223dca6a | 1200 | } |
0b22d65c ZW |
1201 | break; |
1202 | ||
1203 | case 'w': | |
1204 | opts->inhibit_warnings = 1; | |
1205 | break; | |
6de1e2a9 | 1206 | |
0b22d65c ZW |
1207 | case 'W': |
1208 | if (!strcmp (argv[i], "-Wtrigraphs")) | |
6de1e2a9 | 1209 | opts->warn_trigraphs = 1; |
0b22d65c ZW |
1210 | else if (!strcmp (argv[i], "-Wno-trigraphs")) |
1211 | opts->warn_trigraphs = 0; | |
1212 | else if (!strcmp (argv[i], "-Wcomment")) | |
6de1e2a9 | 1213 | opts->warn_comments = 1; |
0b22d65c ZW |
1214 | else if (!strcmp (argv[i], "-Wno-comment")) |
1215 | opts->warn_comments = 0; | |
1216 | else if (!strcmp (argv[i], "-Wcomments")) | |
1217 | opts->warn_comments = 1; | |
1218 | else if (!strcmp (argv[i], "-Wno-comments")) | |
1219 | opts->warn_comments = 0; | |
1220 | else if (!strcmp (argv[i], "-Wtraditional")) | |
1221 | opts->warn_stringify = 1; | |
1222 | else if (!strcmp (argv[i], "-Wno-traditional")) | |
1223 | opts->warn_stringify = 0; | |
1224 | else if (!strcmp (argv[i], "-Wundef")) | |
1225 | opts->warn_undef = 1; | |
1226 | else if (!strcmp (argv[i], "-Wno-undef")) | |
1227 | opts->warn_undef = 0; | |
1228 | else if (!strcmp (argv[i], "-Wimport")) | |
1229 | opts->warn_import = 1; | |
1230 | else if (!strcmp (argv[i], "-Wno-import")) | |
1231 | opts->warn_import = 0; | |
1232 | else if (!strcmp (argv[i], "-Werror")) | |
1233 | opts->warnings_are_errors = 1; | |
1234 | else if (!strcmp (argv[i], "-Wno-error")) | |
1235 | opts->warnings_are_errors = 0; | |
1236 | else if (!strcmp (argv[i], "-Wall")) | |
1237 | { | |
1238 | opts->warn_trigraphs = 1; | |
1239 | opts->warn_comments = 1; | |
1240 | } | |
1241 | break; | |
6de1e2a9 | 1242 | |
0b22d65c ZW |
1243 | case 'M': |
1244 | /* The style of the choices here is a bit mixed. | |
1245 | The chosen scheme is a hybrid of keeping all options in one string | |
1246 | and specifying each option in a separate argument: | |
1247 | -M|-MM|-MD file|-MMD file [-MG]. An alternative is: | |
1248 | -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: | |
1249 | -M[M][G][D file]. This is awkward to handle in specs, and is not | |
1250 | as extensible. */ | |
1251 | /* ??? -MG must be specified in addition to one of -M or -MM. | |
1252 | This can be relaxed in the future without breaking anything. | |
1253 | The converse isn't true. */ | |
6de1e2a9 | 1254 | |
0b22d65c ZW |
1255 | /* -MG isn't valid with -MD or -MMD. This is checked for later. */ |
1256 | if (!strcmp (argv[i], "-MG")) | |
1257 | { | |
1258 | opts->print_deps_missing_files = 1; | |
6de1e2a9 ZW |
1259 | break; |
1260 | } | |
0b22d65c ZW |
1261 | if (!strcmp (argv[i], "-M")) |
1262 | opts->print_deps = 2; | |
1263 | else if (!strcmp (argv[i], "-MM")) | |
1264 | opts->print_deps = 1; | |
1265 | else if (!strcmp (argv[i], "-MD")) | |
1266 | opts->print_deps = 2; | |
1267 | else if (!strcmp (argv[i], "-MMD")) | |
1268 | opts->print_deps = 1; | |
1269 | /* For -MD and -MMD options, write deps on file named by next arg. */ | |
1270 | if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD")) | |
1271 | { | |
1272 | if (i+1 == argc) | |
1273 | goto missing_filename; | |
1274 | opts->deps_file = argv[++i]; | |
1275 | } | |
1276 | else | |
1277 | { | |
1278 | /* For -M and -MM, write deps on standard output | |
1279 | and suppress the usual output. */ | |
1280 | opts->no_output = 1; | |
1281 | } | |
1282 | break; | |
1283 | ||
1284 | case 'd': | |
1285 | { | |
1286 | char *p = argv[i] + 2; | |
1287 | char c; | |
1288 | while ((c = *p++) != 0) | |
1289 | { | |
1290 | /* Arg to -d specifies what parts of macros to dump */ | |
1291 | switch (c) | |
1292 | { | |
1293 | case 'M': | |
1294 | opts->dump_macros = dump_only; | |
1295 | opts->no_output = 1; | |
1296 | break; | |
1297 | case 'N': | |
1298 | opts->dump_macros = dump_names; | |
1299 | break; | |
1300 | case 'D': | |
1301 | opts->dump_macros = dump_definitions; | |
1302 | break; | |
1303 | case 'I': | |
1304 | opts->dump_includes = 1; | |
1305 | break; | |
1306 | } | |
1307 | } | |
6de1e2a9 | 1308 | } |
0b22d65c | 1309 | break; |
6de1e2a9 | 1310 | |
0b22d65c ZW |
1311 | case 'g': |
1312 | if (argv[i][2] == '3') | |
1313 | opts->debug_output = 1; | |
1314 | break; | |
6de1e2a9 | 1315 | |
0b22d65c ZW |
1316 | case '-': |
1317 | if (!strcmp (argv[i], "--help")) | |
1318 | print_help (); | |
1319 | else if (!strcmp (argv[i], "--version")) | |
c1212d2f | 1320 | fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string); |
0b22d65c ZW |
1321 | exit (0); /* XXX */ |
1322 | break; | |
6de1e2a9 | 1323 | |
0b22d65c | 1324 | case 'v': |
c1212d2f | 1325 | fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string); |
6de1e2a9 | 1326 | #ifdef TARGET_VERSION |
0b22d65c | 1327 | TARGET_VERSION; |
6de1e2a9 | 1328 | #endif |
0b22d65c ZW |
1329 | fputc ('\n', stderr); |
1330 | opts->verbose = 1; | |
1331 | break; | |
6de1e2a9 | 1332 | |
0b22d65c ZW |
1333 | case 'H': |
1334 | opts->print_include_names = 1; | |
1335 | break; | |
6de1e2a9 | 1336 | |
0b22d65c | 1337 | case 'D': |
6de1e2a9 | 1338 | { |
223dca6a | 1339 | const char *text; |
0b22d65c | 1340 | if (argv[i][2] != 0) |
223dca6a | 1341 | text = argv[i] + 2; |
0b22d65c ZW |
1342 | else if (i + 1 == argc) |
1343 | { | |
1344 | cpp_fatal (pfile, "Macro name missing after -D option"); | |
1345 | return argc; | |
1346 | } | |
1347 | else | |
223dca6a RH |
1348 | text = argv[++i]; |
1349 | new_pending_define (opts, text); | |
6de1e2a9 | 1350 | } |
0b22d65c | 1351 | break; |
6de1e2a9 | 1352 | |
0b22d65c ZW |
1353 | case 'A': |
1354 | { | |
1355 | char *p; | |
6de1e2a9 | 1356 | |
0b22d65c ZW |
1357 | if (argv[i][2] != 0) |
1358 | p = argv[i] + 2; | |
1359 | else if (i + 1 == argc) | |
1360 | { | |
1361 | cpp_fatal (pfile, "Assertion missing after -A option"); | |
1362 | return argc; | |
1363 | } | |
1364 | else | |
1365 | p = argv[++i]; | |
6de1e2a9 | 1366 | |
0b22d65c | 1367 | if (strcmp (p, "-")) |
6de1e2a9 | 1368 | { |
0b22d65c ZW |
1369 | struct pending_option *o = (struct pending_option *) |
1370 | xmalloc (sizeof (struct pending_option)); | |
1371 | ||
1372 | o->arg = p; | |
1373 | o->next = NULL; | |
1374 | o->undef = 0; | |
1375 | APPEND (opts->pending, assert, o); | |
1376 | } | |
1377 | else | |
1378 | { | |
1379 | /* -A- eliminates all predefined macros and assertions. | |
1380 | Let's include also any that were specified earlier | |
1381 | on the command line. That way we can get rid of any | |
1382 | that were passed automatically in from GCC. */ | |
1383 | struct pending_option *o1, *o2; | |
1384 | ||
1385 | o1 = opts->pending->define_head; | |
1386 | while (o1) | |
1387 | { | |
1388 | o2 = o1->next; | |
1389 | free (o1); | |
1390 | o1 = o2; | |
1391 | } | |
1392 | o1 = opts->pending->assert_head; | |
1393 | while (o1) | |
6de1e2a9 | 1394 | { |
0b22d65c ZW |
1395 | o2 = o1->next; |
1396 | free (o1); | |
1397 | o1 = o2; | |
6de1e2a9 | 1398 | } |
0b22d65c ZW |
1399 | opts->pending->assert_head = NULL; |
1400 | opts->pending->assert_tail = NULL; | |
1401 | opts->pending->define_head = NULL; | |
1402 | opts->pending->define_tail = NULL; | |
6de1e2a9 | 1403 | } |
6de1e2a9 | 1404 | } |
0b22d65c | 1405 | break; |
6de1e2a9 | 1406 | |
0b22d65c | 1407 | case 'U': |
6de1e2a9 | 1408 | { |
0b22d65c ZW |
1409 | struct pending_option *o = (struct pending_option *) |
1410 | xmalloc (sizeof (struct pending_option)); | |
1411 | ||
1412 | if (argv[i][2] != 0) | |
1413 | o->arg = argv[i] + 2; | |
1414 | else if (i + 1 == argc) | |
1415 | { | |
1416 | cpp_fatal (pfile, "Macro name missing after -U option"); | |
1417 | return argc; | |
1418 | } | |
1419 | else | |
1420 | o->arg = argv[++i]; | |
1421 | ||
1422 | o->next = NULL; | |
1423 | o->undef = 1; | |
1424 | APPEND (opts->pending, define, o); | |
6de1e2a9 | 1425 | } |
0b22d65c | 1426 | break; |
6de1e2a9 | 1427 | |
0b22d65c | 1428 | case 'C': |
564ad5f4 | 1429 | opts->discard_comments = 0; |
0b22d65c | 1430 | break; |
6de1e2a9 | 1431 | |
0b22d65c ZW |
1432 | case 'E': /* -E comes from cc -E; ignore it. */ |
1433 | break; | |
6de1e2a9 | 1434 | |
0b22d65c ZW |
1435 | case 'P': |
1436 | opts->no_line_commands = 1; | |
1437 | break; | |
6de1e2a9 | 1438 | |
0b22d65c ZW |
1439 | case '$': /* Don't include $ in identifiers. */ |
1440 | opts->dollars_in_ident = 0; | |
1441 | break; | |
6de1e2a9 | 1442 | |
0b22d65c ZW |
1443 | case 'n': |
1444 | if (!strcmp (argv[i], "-nostdinc")) | |
1445 | /* -nostdinc causes no default include directories. | |
1446 | You must specify all include-file directories with -I. */ | |
1447 | opts->no_standard_includes = 1; | |
1448 | else if (!strcmp (argv[i], "-nostdinc++")) | |
1449 | /* -nostdinc++ causes no default C++-specific include directories. */ | |
1450 | opts->no_standard_cplusplus_includes = 1; | |
0b22d65c | 1451 | break; |
6de1e2a9 | 1452 | |
0b22d65c ZW |
1453 | case 'r': |
1454 | if (!strcmp (argv[i], "-remap")) | |
1455 | opts->remap = 1; | |
1456 | break; | |
6de1e2a9 | 1457 | |
0b22d65c ZW |
1458 | case '\0': /* JF handle '-' as file name meaning stdin or stdout */ |
1459 | if (opts->in_fname == NULL) | |
1460 | opts->in_fname = ""; | |
1461 | else if (opts->out_fname == NULL) | |
1462 | opts->out_fname = ""; | |
1463 | else | |
1464 | return i; /* error */ | |
6de1e2a9 | 1465 | break; |
6de1e2a9 | 1466 | |
0b22d65c ZW |
1467 | default: |
1468 | return i; | |
1469 | } | |
6de1e2a9 ZW |
1470 | |
1471 | return i + 1; | |
0b22d65c ZW |
1472 | |
1473 | missing_filename: | |
1474 | cpp_fatal (pfile, "Filename missing after `%s' option", argv[i]); | |
1475 | return argc; | |
1476 | missing_dirname: | |
1477 | cpp_fatal (pfile, "Directory name missing after `%s' option", argv[i]); | |
1478 | return argc; | |
6de1e2a9 ZW |
1479 | } |
1480 | ||
1481 | /* Handle command-line options in (argc, argv). | |
1482 | Can be called multiple times, to handle multiple sets of options. | |
1483 | Returns if an unrecognized option is seen. | |
1484 | Returns number of strings consumed. */ | |
1485 | ||
1486 | int | |
1487 | cpp_handle_options (pfile, argc, argv) | |
1488 | cpp_reader *pfile; | |
1489 | int argc; | |
1490 | char **argv; | |
1491 | { | |
1492 | int i; | |
1493 | int strings_processed; | |
1494 | for (i = 0; i < argc; i += strings_processed) | |
1495 | { | |
1496 | strings_processed = cpp_handle_option (pfile, argc - i, argv + i); | |
1497 | if (strings_processed == 0) | |
1498 | break; | |
1499 | } | |
1500 | return i; | |
1501 | } | |
1502 | ||
1503 | static void | |
1504 | print_help () | |
1505 | { | |
c1212d2f | 1506 | fprintf (stderr, _("Usage: %s [switches] input output\n"), progname); |
6de1e2a9 ZW |
1507 | fputs (_("\ |
1508 | Switches:\n\ | |
1509 | -include <file> Include the contents of <file> before other files\n\ | |
1510 | -imacros <file> Accept definition of macros in <file>\n\ | |
1511 | -iprefix <path> Specify <path> as a prefix for next two options\n\ | |
1512 | -iwithprefix <dir> Add <dir> to the end of the system include path\n\ | |
1513 | -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\ | |
1514 | -isystem <dir> Add <dir> to the start of the system include path\n\ | |
1515 | -idirafter <dir> Add <dir> to the end of the system include path\n\ | |
1516 | -I <dir> Add <dir> to the end of the main include path\n\ | |
1517 | -nostdinc Do not search system include directories\n\ | |
1518 | (dirs specified with -isystem will still be used)\n\ | |
1519 | -nostdinc++ Do not search system include directories for C++\n\ | |
1520 | -o <file> Put output into <file>\n\ | |
1521 | -pedantic Issue all warnings demanded by strict ANSI C\n\ | |
1522 | -traditional Follow K&R pre-processor behaviour\n\ | |
1523 | -trigraphs Support ANSI C trigraphs\n\ | |
1524 | -lang-c Assume that the input sources are in C\n\ | |
1525 | -lang-c89 Assume that the input sources are in C89\n\ | |
1526 | -lang-c++ Assume that the input sources are in C++\n\ | |
1527 | -lang-objc Assume that the input sources are in ObjectiveC\n\ | |
1528 | -lang-objc++ Assume that the input sources are in ObjectiveC++\n\ | |
1529 | -lang-asm Assume that the input sources are in assembler\n\ | |
40c79d58 | 1530 | -lang-fortran Assume that the input sources are in Fortran\n\ |
6de1e2a9 ZW |
1531 | -lang-chill Assume that the input sources are in Chill\n\ |
1532 | -std=<std name> Specify the conformance standard; one of:\n\ | |
916269ab UD |
1533 | gnu89, gnu99, c89, c99, iso9899:1990,\n\ |
1534 | iso9899:199409, iso9899:1999\n\ | |
6de1e2a9 ZW |
1535 | -+ Allow parsing of C++ style features\n\ |
1536 | -w Inhibit warning messages\n\ | |
1537 | -Wtrigraphs Warn if trigraphs are encountered\n\ | |
1538 | -Wno-trigraphs Do not warn about trigraphs\n\ | |
1539 | -Wcomment{s} Warn if one comment starts inside another\n\ | |
1540 | -Wno-comment{s} Do not warn about comments\n\ | |
1541 | -Wtraditional Warn if a macro argument is/would be turned into\n\ | |
1542 | a string if -traditional is specified\n\ | |
1543 | -Wno-traditional Do not warn about stringification\n\ | |
1544 | -Wundef Warn if an undefined macro is used by #if\n\ | |
1545 | -Wno-undef Do not warn about testing undefined macros\n\ | |
1546 | -Wimport Warn about the use of the #import directive\n\ | |
1547 | -Wno-import Do not warn about the use of #import\n\ | |
1548 | -Werror Treat all warnings as errors\n\ | |
1549 | -Wno-error Do not treat warnings as errors\n\ | |
1550 | -Wall Enable all preprocessor warnings\n\ | |
1551 | -M Generate make dependencies\n\ | |
1552 | -MM As -M, but ignore system header files\n\ | |
1553 | -MD As -M, but put output in a .d file\n\ | |
1554 | -MMD As -MD, but ignore system header files\n\ | |
1555 | -MG Treat missing header file as generated files\n\ | |
1556 | -g Include #define and #undef directives in the output\n\ | |
1557 | -D<macro> Define a <macro> with string '1' as its value\n\ | |
1558 | -D<macro>=<val> Define a <macro> with <val> as its value\n\ | |
1559 | -A<question> (<answer>) Assert the <answer> to <question>\n\ | |
1560 | -U<macro> Undefine <macro> \n\ | |
6de1e2a9 ZW |
1561 | -v Display the version number\n\ |
1562 | -H Print the name of header files as they are used\n\ | |
1563 | -C Do not discard comments\n\ | |
1564 | -dM Display a list of macro definitions active at end\n\ | |
1565 | -dD Preserve macro definitions in output\n\ | |
1566 | -dN As -dD except that only the names are preserved\n\ | |
1567 | -dI Include #include directives in the output\n\ | |
6de1e2a9 ZW |
1568 | -P Do not generate #line directives\n\ |
1569 | -$ Do not allow '$' in identifiers\n\ | |
1570 | -remap Remap file names when including files.\n\ | |
1571 | -h or --help Display this information\n\ | |
1572 | "), stdout); | |
1573 | } |