Daily bump.
[official-gcc.git] / gcc / cppinit.c
blob7e04c3acc55bbe0081101bbd5b758508195e5de4
1 /* CPP Library.
2 Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
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
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.
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.
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. */
22 #include "config.h"
23 #include "system.h"
24 #include "cpplib.h"
25 #include "cpphash.h"
26 #include "prefix.h"
27 #include "intl.h"
28 #include "version.h"
29 #include "mkdeps.h"
30 #include "cppdefault.h"
31 #include "except.h" /* for USING_SJLJ_EXCEPTIONS */
33 /* Predefined symbols, built-in macros, and the default include path. */
35 #ifndef GET_ENV_PATH_LIST
36 #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
37 #endif
39 /* Windows does not natively support inodes, and neither does MSDOS.
40 Cygwin's emulation can generate non-unique inodes, so don't use it.
41 VMS has non-numeric inodes. */
42 #ifdef VMS
43 # define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
44 # define INO_T_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof (SRC))
45 #else
46 # if (defined _WIN32 && ! defined (_UWIN)) || defined __MSDOS__
47 # define INO_T_EQ(A, B) 0
48 # else
49 # define INO_T_EQ(A, B) ((A) == (B))
50 # endif
51 # define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
52 #endif
54 /* Internal structures and prototypes. */
56 /* A `struct pending_option' remembers one -D, -A, -U, -include, or
57 -imacros switch. */
58 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
59 struct pending_option
61 struct pending_option *next;
62 const char *arg;
63 cl_directive_handler handler;
66 /* The `pending' structure accumulates all the options that are not
67 actually processed until we hit cpp_read_main_file. It consists of
68 several lists, one for each type of option. We keep both head and
69 tail pointers for quick insertion. */
70 struct cpp_pending
72 struct pending_option *directive_head, *directive_tail;
74 struct search_path *quote_head, *quote_tail;
75 struct search_path *brack_head, *brack_tail;
76 struct search_path *systm_head, *systm_tail;
77 struct search_path *after_head, *after_tail;
79 struct pending_option *imacros_head, *imacros_tail;
80 struct pending_option *include_head, *include_tail;
83 #ifdef __STDC__
84 #define APPEND(pend, list, elt) \
85 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
86 else (pend)->list##_tail->next = (elt); \
87 (pend)->list##_tail = (elt); \
88 } while (0)
89 #else
90 #define APPEND(pend, list, elt) \
91 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
92 else (pend)->list/**/_tail->next = (elt); \
93 (pend)->list/**/_tail = (elt); \
94 } while (0)
95 #endif
97 static void print_help PARAMS ((void));
98 static void path_include PARAMS ((cpp_reader *,
99 char *, int));
100 static void init_library PARAMS ((void));
101 static void init_builtins PARAMS ((cpp_reader *));
102 static void mark_named_operators PARAMS ((cpp_reader *));
103 static void append_include_chain PARAMS ((cpp_reader *,
104 char *, int, int));
105 static struct search_path * remove_dup_dir PARAMS ((cpp_reader *,
106 struct search_path *));
107 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
108 struct search_path *));
109 static void merge_include_chains PARAMS ((cpp_reader *));
110 static bool push_include PARAMS ((cpp_reader *,
111 struct pending_option *));
112 static void free_chain PARAMS ((struct pending_option *));
113 static void set_lang PARAMS ((cpp_reader *, enum c_lang));
114 static void init_dependency_output PARAMS ((cpp_reader *));
115 static void init_standard_includes PARAMS ((cpp_reader *));
116 static void read_original_filename PARAMS ((cpp_reader *));
117 static void new_pending_directive PARAMS ((struct cpp_pending *,
118 const char *,
119 cl_directive_handler));
120 static void output_deps PARAMS ((cpp_reader *));
121 static int parse_option PARAMS ((const char *));
123 /* Fourth argument to append_include_chain: chain to use.
124 Note it's never asked to append to the quote chain. */
125 enum { BRACKET = 0, SYSTEM, AFTER };
127 /* If we have designated initializers (GCC >2.7) these tables can be
128 initialized, constant data. Otherwise, they have to be filled in at
129 runtime. */
130 #if HAVE_DESIGNATED_INITIALIZERS
132 #define init_trigraph_map() /* Nothing. */
133 #define TRIGRAPH_MAP \
134 __extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
136 #define END };
137 #define s(p, v) [p] = v,
139 #else
141 #define TRIGRAPH_MAP U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
142 static void init_trigraph_map PARAMS ((void)) { \
143 unsigned char *x = _cpp_trigraph_map;
145 #define END }
146 #define s(p, v) x[p] = v;
148 #endif
150 TRIGRAPH_MAP
151 s('=', '#') s(')', ']') s('!', '|')
152 s('(', '[') s('\'', '^') s('>', '}')
153 s('/', '\\') s('<', '{') s('-', '~')
156 #undef s
157 #undef END
158 #undef TRIGRAPH_MAP
160 /* Given a colon-separated list of file names PATH,
161 add all the names to the search path for include files. */
162 static void
163 path_include (pfile, list, path)
164 cpp_reader *pfile;
165 char *list;
166 int path;
168 char *p, *q, *name;
170 p = list;
174 /* Find the end of this name. */
175 q = p;
176 while (*q != 0 && *q != PATH_SEPARATOR) q++;
177 if (q == p)
179 /* An empty name in the path stands for the current directory. */
180 name = (char *) xmalloc (2);
181 name[0] = '.';
182 name[1] = 0;
184 else
186 /* Otherwise use the directory that is named. */
187 name = (char *) xmalloc (q - p + 1);
188 memcpy (name, p, q - p);
189 name[q - p] = 0;
192 append_include_chain (pfile, name, path, 0);
194 /* Advance past this name. */
195 if (*q == 0)
196 break;
197 p = q + 1;
199 while (1);
202 /* Append DIR to include path PATH. DIR must be allocated on the
203 heap; this routine takes responsibility for freeing it. CXX_AWARE
204 is non-zero if the header contains extern "C" guards for C++,
205 otherwise it is zero. */
206 static void
207 append_include_chain (pfile, dir, path, cxx_aware)
208 cpp_reader *pfile;
209 char *dir;
210 int path;
211 int cxx_aware ATTRIBUTE_UNUSED;
213 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
214 struct search_path *new;
215 struct stat st;
216 unsigned int len;
218 if (*dir == '\0')
220 free (dir);
221 dir = xstrdup (".");
223 _cpp_simplify_pathname (dir);
225 if (stat (dir, &st))
227 /* Dirs that don't exist are silently ignored. */
228 if (errno != ENOENT)
229 cpp_notice_from_errno (pfile, dir);
230 else if (CPP_OPTION (pfile, verbose))
231 fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
232 free (dir);
233 return;
236 if (!S_ISDIR (st.st_mode))
238 cpp_notice (pfile, "%s: Not a directory", dir);
239 free (dir);
240 return;
243 len = strlen (dir);
244 if (len > pfile->max_include_len)
245 pfile->max_include_len = len;
247 new = (struct search_path *) xmalloc (sizeof (struct search_path));
248 new->name = dir;
249 new->len = len;
250 INO_T_COPY (new->ino, st.st_ino);
251 new->dev = st.st_dev;
252 /* Both systm and after include file lists should be treated as system
253 include files since these two lists are really just a concatenation
254 of one "system" list. */
255 if (path == SYSTEM || path == AFTER)
256 #ifdef NO_IMPLICIT_EXTERN_C
257 new->sysp = 1;
258 #else
259 new->sysp = cxx_aware ? 1 : 2;
260 #endif
261 else
262 new->sysp = 0;
263 new->name_map = NULL;
264 new->next = NULL;
266 switch (path)
268 case BRACKET: APPEND (pend, brack, new); break;
269 case SYSTEM: APPEND (pend, systm, new); break;
270 case AFTER: APPEND (pend, after, new); break;
274 /* Handle a duplicated include path. PREV is the link in the chain
275 before the duplicate. The duplicate is removed from the chain and
276 freed. Returns PREV. */
277 static struct search_path *
278 remove_dup_dir (pfile, prev)
279 cpp_reader *pfile;
280 struct search_path *prev;
282 struct search_path *cur = prev->next;
284 if (CPP_OPTION (pfile, verbose))
285 fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
287 prev->next = cur->next;
288 free ((PTR) cur->name);
289 free (cur);
291 return prev;
294 /* Remove duplicate directories from a chain. Returns the tail of the
295 chain, or NULL if the chain is empty. This algorithm is quadratic
296 in the number of -I switches, which is acceptable since there
297 aren't usually that many of them. */
298 static struct search_path *
299 remove_dup_dirs (pfile, head)
300 cpp_reader *pfile;
301 struct search_path *head;
303 struct search_path *prev = NULL, *cur, *other;
305 for (cur = head; cur; cur = cur->next)
307 for (other = head; other != cur; other = other->next)
308 if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
310 if (cur->sysp && !other->sysp)
312 cpp_warning (pfile,
313 "changing search order for system directory \"%s\"",
314 cur->name);
315 if (strcmp (cur->name, other->name))
316 cpp_warning (pfile,
317 " as it is the same as non-system directory \"%s\"",
318 other->name);
319 else
320 cpp_warning (pfile,
321 " as it has already been specified as a non-system directory");
323 cur = remove_dup_dir (pfile, prev);
324 break;
326 prev = cur;
329 return prev;
332 /* Merge the four include chains together in the order quote, bracket,
333 system, after. Remove duplicate dirs (as determined by
334 INO_T_EQ()). The system_include and after_include chains are never
335 referred to again after this function; all access is through the
336 bracket_include path. */
337 static void
338 merge_include_chains (pfile)
339 cpp_reader *pfile;
341 struct search_path *quote, *brack, *systm, *qtail;
343 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
345 quote = pend->quote_head;
346 brack = pend->brack_head;
347 systm = pend->systm_head;
348 qtail = pend->quote_tail;
350 /* Paste together bracket, system, and after include chains. */
351 if (systm)
352 pend->systm_tail->next = pend->after_head;
353 else
354 systm = pend->after_head;
356 if (brack)
357 pend->brack_tail->next = systm;
358 else
359 brack = systm;
361 /* This is a bit tricky. First we drop dupes from the quote-include
362 list. Then we drop dupes from the bracket-include list.
363 Finally, if qtail and brack are the same directory, we cut out
364 brack and move brack up to point to qtail.
366 We can't just merge the lists and then uniquify them because
367 then we may lose directories from the <> search path that should
368 be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
369 safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
370 -Ibar -I- -Ifoo -Iquux. */
372 remove_dup_dirs (pfile, brack);
373 qtail = remove_dup_dirs (pfile, quote);
375 if (quote)
377 qtail->next = brack;
379 /* If brack == qtail, remove brack as it's simpler. */
380 if (brack && INO_T_EQ (qtail->ino, brack->ino)
381 && qtail->dev == brack->dev)
382 brack = remove_dup_dir (pfile, qtail);
384 else
385 quote = brack;
387 CPP_OPTION (pfile, quote_include) = quote;
388 CPP_OPTION (pfile, bracket_include) = brack;
391 /* A set of booleans indicating what CPP features each source language
392 requires. */
393 struct lang_flags
395 char c99;
396 char objc;
397 char cplusplus;
398 char extended_numbers;
399 char trigraphs;
400 char dollars_in_ident;
401 char cplusplus_comments;
402 char digraphs;
405 /* ??? Enable $ in identifiers in assembly? */
406 static const struct lang_flags lang_defaults[] =
407 { /* c99 objc c++ xnum trig dollar c++comm digr */
408 /* GNUC89 */ { 0, 0, 0, 1, 0, 1, 1, 1 },
409 /* GNUC99 */ { 1, 0, 0, 1, 0, 1, 1, 1 },
410 /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0 },
411 /* STDC94 */ { 0, 0, 0, 0, 1, 0, 0, 1 },
412 /* STDC99 */ { 1, 0, 0, 1, 1, 0, 1, 1 },
413 /* GNUCXX */ { 0, 0, 1, 1, 0, 1, 1, 1 },
414 /* CXX98 */ { 0, 0, 1, 1, 1, 0, 1, 1 },
415 /* OBJC */ { 0, 1, 0, 1, 0, 1, 1, 1 },
416 /* OBJCXX */ { 0, 1, 1, 1, 0, 1, 1, 1 },
417 /* ASM */ { 0, 0, 0, 1, 0, 0, 1, 0 }
420 /* Sets internal flags correctly for a given language. */
421 static void
422 set_lang (pfile, lang)
423 cpp_reader *pfile;
424 enum c_lang lang;
426 const struct lang_flags *l = &lang_defaults[(int) lang];
428 CPP_OPTION (pfile, lang) = lang;
430 CPP_OPTION (pfile, c99) = l->c99;
431 CPP_OPTION (pfile, objc) = l->objc;
432 CPP_OPTION (pfile, cplusplus) = l->cplusplus;
433 CPP_OPTION (pfile, extended_numbers) = l->extended_numbers;
434 CPP_OPTION (pfile, trigraphs) = l->trigraphs;
435 CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident;
436 CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments;
437 CPP_OPTION (pfile, digraphs) = l->digraphs;
440 #ifdef HOST_EBCDIC
441 static int opt_comp PARAMS ((const void *, const void *));
443 /* Run-time sorting of options array. */
444 static int
445 opt_comp (p1, p2)
446 const void *p1, *p2;
448 return strcmp (((struct cl_option *) p1)->opt_text,
449 ((struct cl_option *) p2)->opt_text);
451 #endif
453 /* init initializes library global state. It might not need to
454 do anything depending on the platform and compiler. */
455 static void
456 init_library ()
458 static int initialized = 0;
460 if (! initialized)
462 initialized = 1;
464 #ifdef HOST_EBCDIC
465 /* For non-ASCII hosts, the cl_options array needs to be sorted at
466 runtime. */
467 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
468 #endif
470 /* Set up the trigraph map. This doesn't need to do anything if
471 we were compiled with a compiler that supports C99 designated
472 initializers. */
473 init_trigraph_map ();
477 /* Initialize a cpp_reader structure. */
478 cpp_reader *
479 cpp_create_reader (lang)
480 enum c_lang lang;
482 cpp_reader *pfile;
484 /* Initialise this instance of the library if it hasn't been already. */
485 init_library ();
487 pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
489 set_lang (pfile, lang);
490 CPP_OPTION (pfile, warn_import) = 1;
491 CPP_OPTION (pfile, discard_comments) = 1;
492 CPP_OPTION (pfile, show_column) = 1;
493 CPP_OPTION (pfile, tabstop) = 8;
494 CPP_OPTION (pfile, operator_names) = 1;
495 #if DEFAULT_SIGNED_CHAR
496 CPP_OPTION (pfile, signed_char) = 1;
497 #else
498 CPP_OPTION (pfile, signed_char) = 0;
499 #endif
501 CPP_OPTION (pfile, pending) =
502 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
504 /* It's simplest to just create this struct whether or not it will
505 be needed. */
506 pfile->deps = deps_init ();
508 /* Initialise the line map. Start at logical line 1, so we can use
509 a line number of zero for special states. */
510 init_line_maps (&pfile->line_maps);
511 pfile->line = 1;
513 /* Initialize lexer state. */
514 pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
516 /* Set up static tokens. */
517 pfile->date.type = CPP_EOF;
518 pfile->avoid_paste.type = CPP_PADDING;
519 pfile->avoid_paste.val.source = NULL;
520 pfile->eof.type = CPP_EOF;
521 pfile->eof.flags = 0;
523 /* Create a token buffer for the lexer. */
524 _cpp_init_tokenrun (&pfile->base_run, 250);
525 pfile->cur_run = &pfile->base_run;
526 pfile->cur_token = pfile->base_run.base;
528 /* Initialise the base context. */
529 pfile->context = &pfile->base_context;
530 pfile->base_context.macro = 0;
531 pfile->base_context.prev = pfile->base_context.next = 0;
533 /* Aligned and unaligned storage. */
534 pfile->a_buff = _cpp_get_buff (pfile, 0);
535 pfile->u_buff = _cpp_get_buff (pfile, 0);
537 /* Initialise the buffer obstack. */
538 gcc_obstack_init (&pfile->buffer_ob);
540 _cpp_init_includes (pfile);
542 return pfile;
545 /* Free resources used by PFILE. Accessing PFILE after this function
546 returns leads to undefined behaviour. Returns the error count. */
548 cpp_destroy (pfile)
549 cpp_reader *pfile;
551 int result;
552 struct search_path *dir, *dirn;
553 cpp_context *context, *contextn;
554 tokenrun *run, *runn;
556 while (CPP_BUFFER (pfile) != NULL)
557 _cpp_pop_buffer (pfile);
559 if (pfile->macro_buffer)
561 free ((PTR) pfile->macro_buffer);
562 pfile->macro_buffer = NULL;
563 pfile->macro_buffer_len = 0;
566 deps_free (pfile->deps);
567 obstack_free (&pfile->buffer_ob, 0);
569 _cpp_destroy_hashtable (pfile);
570 _cpp_cleanup_includes (pfile);
572 _cpp_free_buff (pfile->a_buff);
573 _cpp_free_buff (pfile->u_buff);
574 _cpp_free_buff (pfile->free_buffs);
576 for (run = &pfile->base_run; run; run = runn)
578 runn = run->next;
579 free (run->base);
580 if (run != &pfile->base_run)
581 free (run);
584 for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
586 dirn = dir->next;
587 free ((PTR) dir->name);
588 free (dir);
591 for (context = pfile->base_context.next; context; context = contextn)
593 contextn = context->next;
594 free (context);
597 free_line_maps (&pfile->line_maps);
599 result = pfile->errors;
600 free (pfile);
602 return result;
606 /* This structure defines one built-in identifier. A node will be
607 entered in the hash table under the name NAME, with value VALUE (if
608 any). If flags has OPERATOR, the node's operator field is used; if
609 flags has BUILTIN the node's builtin field is used. Macros that are
610 known at build time should not be flagged BUILTIN, as then they do
611 not appear in macro dumps with e.g. -dM or -dD.
613 Two values are not compile time constants, so we tag
614 them in the FLAGS field instead:
615 VERS value is the global version_string, quoted
616 ULP value is the global user_label_prefix */
617 struct builtin
619 const U_CHAR *name;
620 const char *value;
621 unsigned char builtin;
622 unsigned short flags;
623 unsigned short len;
625 #define VERS 0x01
626 #define ULP 0x02
627 #define BUILTIN 0x08
629 #define B(n, t) { U n, 0, t, BUILTIN, sizeof n - 1 }
630 #define C(n, v) { U n, v, 0, 0, sizeof n - 1 }
631 #define X(n, f) { U n, 0, 0, f, sizeof n - 1 }
632 static const struct builtin builtin_array[] =
634 B("__TIME__", BT_TIME),
635 B("__DATE__", BT_DATE),
636 B("__FILE__", BT_FILE),
637 B("__BASE_FILE__", BT_BASE_FILE),
638 B("__LINE__", BT_SPECLINE),
639 B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
640 B("_Pragma", BT_PRAGMA),
642 X("__VERSION__", VERS),
643 X("__USER_LABEL_PREFIX__", ULP),
644 C("__REGISTER_PREFIX__", REGISTER_PREFIX),
645 C("__HAVE_BUILTIN_SETJMP__", "1"),
646 #if USING_SJLJ_EXCEPTIONS
647 /* libgcc needs to know this. */
648 C("__USING_SJLJ_EXCEPTIONS__","1"),
649 #endif
650 #ifndef NO_BUILTIN_SIZE_TYPE
651 C("__SIZE_TYPE__", SIZE_TYPE),
652 #endif
653 #ifndef NO_BUILTIN_PTRDIFF_TYPE
654 C("__PTRDIFF_TYPE__", PTRDIFF_TYPE),
655 #endif
656 #ifndef NO_BUILTIN_WCHAR_TYPE
657 C("__WCHAR_TYPE__", WCHAR_TYPE),
658 #endif
659 #ifndef NO_BUILTIN_WINT_TYPE
660 C("__WINT_TYPE__", WINT_TYPE),
661 #endif
662 #ifdef STDC_0_IN_SYSTEM_HEADERS
663 B("__STDC__", BT_STDC),
664 #else
665 C("__STDC__", "1"),
666 #endif
668 #undef B
669 #undef C
670 #undef X
671 #define builtin_array_end \
672 builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
674 /* Named operators known to the preprocessor. These cannot be
675 #defined and always have their stated meaning. They are treated
676 like normal identifiers except for the type code and the meaning.
677 Most of them are only for C++ (but see iso646.h). */
678 #define B(n, t) { DSC(n), t }
679 static const struct named_op
681 const U_CHAR *name;
682 unsigned int len;
683 enum cpp_ttype value;
684 } operator_array[] = {
685 B("and", CPP_AND_AND),
686 B("and_eq", CPP_AND_EQ),
687 B("bitand", CPP_AND),
688 B("bitor", CPP_OR),
689 B("compl", CPP_COMPL),
690 B("not", CPP_NOT),
691 B("not_eq", CPP_NOT_EQ),
692 B("or", CPP_OR_OR),
693 B("or_eq", CPP_OR_EQ),
694 B("xor", CPP_XOR),
695 B("xor_eq", CPP_XOR_EQ)
697 #undef B
699 /* Mark the C++ named operators in the hash table. */
700 static void
701 mark_named_operators (pfile)
702 cpp_reader *pfile;
704 const struct named_op *b;
706 for (b = operator_array;
707 b < (operator_array + ARRAY_SIZE (operator_array));
708 b++)
710 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
711 hp->flags |= NODE_OPERATOR;
712 hp->value.operator = b->value;
716 /* Subroutine of cpp_read_main_file; reads the builtins table above and
717 enters them, and language-specific macros, into the hash table. */
718 static void
719 init_builtins (pfile)
720 cpp_reader *pfile;
722 const struct builtin *b;
724 for(b = builtin_array; b < builtin_array_end; b++)
726 if (b->flags & BUILTIN)
728 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
729 hp->type = NT_MACRO;
730 hp->flags |= NODE_BUILTIN | NODE_WARN;
731 hp->value.builtin = b->builtin;
733 else /* A standard macro of some kind. */
735 const char *val;
736 char *str;
738 if (b->flags & VERS)
740 /* Allocate enough space for 'name "value"\n\0'. */
741 str = alloca (b->len + strlen (version_string) + 5);
742 sprintf (str, "%s \"%s\"\n", b->name, version_string);
744 else
746 if (b->flags & ULP)
747 val = CPP_OPTION (pfile, user_label_prefix);
748 else
749 val = b->value;
751 /* Allocate enough space for "name value\n\0". */
752 str = alloca (b->len + strlen (val) + 3);
753 sprintf(str, "%s %s\n", b->name, val);
756 _cpp_define_builtin (pfile, str);
760 if (CPP_OPTION (pfile, cplusplus))
762 _cpp_define_builtin (pfile, "__cplusplus 1");
763 if (SUPPORTS_ONE_ONLY)
764 _cpp_define_builtin (pfile, "__GXX_WEAK__ 1");
765 else
766 _cpp_define_builtin (pfile, "__GXX_WEAK__ 0");
768 if (CPP_OPTION (pfile, objc))
769 _cpp_define_builtin (pfile, "__OBJC__ 1");
771 if (CPP_OPTION (pfile, lang) == CLK_STDC94)
772 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
773 else if (CPP_OPTION (pfile, c99))
774 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
776 if (CPP_OPTION (pfile, signed_char) == 0)
777 _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
779 if (CPP_OPTION (pfile, lang) == CLK_STDC89
780 || CPP_OPTION (pfile, lang) == CLK_STDC94
781 || CPP_OPTION (pfile, lang) == CLK_STDC99)
782 _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
783 else if (CPP_OPTION (pfile, lang) == CLK_ASM)
784 _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
786 #undef BUILTIN
787 #undef OPERATOR
788 #undef VERS
789 #undef ULP
790 #undef builtin_array_end
792 /* And another subroutine. This one sets up the standard include path. */
793 static void
794 init_standard_includes (pfile)
795 cpp_reader *pfile;
797 char *path;
798 const struct default_include *p;
799 const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
801 /* Several environment variables may add to the include search path.
802 CPATH specifies an additional list of directories to be searched
803 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
804 etc. specify an additional list of directories to be searched as
805 if specified with -isystem, for the language indicated. */
807 GET_ENV_PATH_LIST (path, "CPATH");
808 if (path != 0 && *path != 0)
809 path_include (pfile, path, BRACKET);
811 switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
813 case 0:
814 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
815 break;
816 case 1:
817 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
818 break;
819 case 2:
820 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
821 break;
822 case 3:
823 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
824 break;
826 if (path != 0 && *path != 0)
827 path_include (pfile, path, SYSTEM);
829 /* Search "translated" versions of GNU directories.
830 These have /usr/local/lib/gcc... replaced by specd_prefix. */
831 if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
833 /* Remove the `include' from /usr/local/lib/gcc.../include.
834 GCC_INCLUDE_DIR will always end in /include. */
835 int default_len = cpp_GCC_INCLUDE_DIR_len;
836 char *default_prefix = (char *) alloca (default_len + 1);
837 int specd_len = strlen (specd_prefix);
839 memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
840 default_prefix[default_len] = '\0';
842 for (p = cpp_include_defaults; p->fname; p++)
844 /* Some standard dirs are only for C++. */
845 if (!p->cplusplus
846 || (CPP_OPTION (pfile, cplusplus)
847 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
849 /* Does this dir start with the prefix? */
850 if (!memcmp (p->fname, default_prefix, default_len))
852 /* Yes; change prefix and add to search list. */
853 int flen = strlen (p->fname);
854 int this_len = specd_len + flen - default_len;
855 char *str = (char *) xmalloc (this_len + 1);
856 memcpy (str, specd_prefix, specd_len);
857 memcpy (str + specd_len,
858 p->fname + default_len,
859 flen - default_len + 1);
861 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
867 /* Search ordinary names for GNU include directories. */
868 for (p = cpp_include_defaults; p->fname; p++)
870 /* Some standard dirs are only for C++. */
871 if (!p->cplusplus
872 || (CPP_OPTION (pfile, cplusplus)
873 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
875 char *str = update_path (p->fname, p->component);
876 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
881 /* Pushes a command line -imacro and -include file indicated by P onto
882 the buffer stack. Returns non-zero if successful. */
883 static bool
884 push_include (pfile, p)
885 cpp_reader *pfile;
886 struct pending_option *p;
888 cpp_token header;
890 /* Later: maybe update this to use the #include "" search path
891 if cpp_read_file fails. */
892 header.type = CPP_STRING;
893 header.val.str.text = (const unsigned char *) p->arg;
894 header.val.str.len = strlen (p->arg);
895 /* Make the command line directive take up a line. */
896 pfile->line++;
898 return _cpp_execute_include (pfile, &header, IT_CMDLINE);
901 /* Frees a pending_option chain. */
902 static void
903 free_chain (head)
904 struct pending_option *head;
906 struct pending_option *next;
908 while (head)
910 next = head->next;
911 free (head);
912 head = next;
916 /* This is called after options have been parsed, and partially
917 processed. Setup for processing input from the file named FNAME,
918 or stdin if it is the empty string. Return the original filename
919 on success (e.g. foo.i->foo.c), or NULL on failure. */
920 const char *
921 cpp_read_main_file (pfile, fname, table)
922 cpp_reader *pfile;
923 const char *fname;
924 hash_table *table;
926 /* The front ends don't set up the hash table until they have
927 finished processing the command line options, so initializing the
928 hashtable is deferred until now. */
929 _cpp_init_hashtable (pfile, table);
931 /* Set up the include search path now. */
932 if (! CPP_OPTION (pfile, no_standard_includes))
933 init_standard_includes (pfile);
935 merge_include_chains (pfile);
937 /* With -v, print the list of dirs to search. */
938 if (CPP_OPTION (pfile, verbose))
940 struct search_path *l;
941 fprintf (stderr, _("#include \"...\" search starts here:\n"));
942 for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
944 if (l == CPP_OPTION (pfile, bracket_include))
945 fprintf (stderr, _("#include <...> search starts here:\n"));
946 fprintf (stderr, " %s\n", l->name);
948 fprintf (stderr, _("End of search list.\n"));
951 if (CPP_OPTION (pfile, print_deps))
952 /* Set the default target (if there is none already). */
953 deps_add_default_target (pfile->deps, fname);
955 /* Open the main input file. */
956 if (!_cpp_read_file (pfile, fname))
957 return NULL;
959 /* Set this after cpp_post_options so the client can change the
960 option if it wishes, and after stacking the main file so we don't
961 trace the main file. */
962 pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
964 /* For foo.i, read the original filename foo.c now, for the benefit
965 of the front ends. */
966 if (CPP_OPTION (pfile, preprocessed))
967 read_original_filename (pfile);
969 return pfile->map->to_file;
972 /* For preprocessed files, if the first tokens are of the form # NUM.
973 handle the directive so we know the original file name. This will
974 generate file_change callbacks, which the front ends must handle
975 appropriately given their state of initialization. */
976 static void
977 read_original_filename (pfile)
978 cpp_reader *pfile;
980 const cpp_token *token, *token1;
982 /* Lex ahead; if the first tokens are of the form # NUM, then
983 process the directive, otherwise back up. */
984 token = _cpp_lex_direct (pfile);
985 if (token->type == CPP_HASH)
987 token1 = _cpp_lex_direct (pfile);
988 _cpp_backup_tokens (pfile, 1);
990 /* If it's a #line directive, handle it. */
991 if (token1->type == CPP_NUMBER)
993 _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
994 return;
998 /* Backup as if nothing happened. */
999 _cpp_backup_tokens (pfile, 1);
1002 /* Handle pending command line options: -D, -U, -A, -imacros and
1003 -include. This should be called after debugging has been properly
1004 set up in the front ends. */
1005 void
1006 cpp_finish_options (pfile)
1007 cpp_reader *pfile;
1009 /* Mark named operators before handling command line macros. */
1010 if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
1011 mark_named_operators (pfile);
1013 /* Install builtins and process command line macros etc. in the order
1014 they appeared, but only if not already preprocessed. */
1015 if (! CPP_OPTION (pfile, preprocessed))
1017 struct pending_option *p;
1019 _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
1020 init_builtins (pfile);
1021 _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
1022 for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
1023 (*p->handler) (pfile, p->arg);
1025 /* Scan -imacros files after command line defines, but before
1026 files given with -include. */
1027 while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
1029 if (push_include (pfile, p))
1031 pfile->buffer->return_at_eof = true;
1032 cpp_scan_nooutput (pfile);
1034 CPP_OPTION (pfile, pending)->imacros_head = p->next;
1035 free (p);
1039 free_chain (CPP_OPTION (pfile, pending)->directive_head);
1040 _cpp_push_next_buffer (pfile);
1043 /* Called to push the next buffer on the stack given by -include. If
1044 there are none, free the pending structure and restore the line map
1045 for the main file. */
1046 bool
1047 _cpp_push_next_buffer (pfile)
1048 cpp_reader *pfile;
1050 bool pushed = false;
1052 /* This is't pretty; we'd rather not be relying on this as a boolean
1053 for reverting the line map. Further, we only free the chains in
1054 this conditional, so an early call to cpp_finish / cpp_destroy
1055 will leak that memory. */
1056 if (CPP_OPTION (pfile, pending)
1057 && CPP_OPTION (pfile, pending)->imacros_head == NULL)
1059 while (!pushed)
1061 struct pending_option *p = CPP_OPTION (pfile, pending)->include_head;
1063 if (p == NULL)
1064 break;
1065 if (! CPP_OPTION (pfile, preprocessed))
1066 pushed = push_include (pfile, p);
1067 CPP_OPTION (pfile, pending)->include_head = p->next;
1068 free (p);
1071 if (!pushed)
1073 free (CPP_OPTION (pfile, pending));
1074 CPP_OPTION (pfile, pending) = NULL;
1076 /* Restore the line map for the main file. */
1077 if (! CPP_OPTION (pfile, preprocessed))
1078 _cpp_do_file_change (pfile, LC_RENAME,
1079 pfile->line_maps.maps[0].to_file, 1, 0);
1083 return pushed;
1086 /* Use mkdeps.c to output dependency information. */
1087 static void
1088 output_deps (pfile)
1089 cpp_reader *pfile;
1091 /* Stream on which to print the dependency information. */
1092 FILE *deps_stream = 0;
1093 const char *const deps_mode =
1094 CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1096 if (CPP_OPTION (pfile, deps_file)[0] == '\0')
1097 deps_stream = stdout;
1098 else
1100 deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1101 if (deps_stream == 0)
1103 cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
1104 return;
1108 deps_write (pfile->deps, deps_stream, 72);
1110 if (CPP_OPTION (pfile, deps_phony_targets))
1111 deps_phony_targets (pfile->deps, deps_stream);
1113 /* Don't close stdout. */
1114 if (deps_stream != stdout)
1116 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1117 cpp_fatal (pfile, "I/O error on output");
1121 /* This is called at the end of preprocessing. It pops the
1122 last buffer and writes dependency output. It should also
1123 clear macro definitions, such that you could call cpp_start_read
1124 with a new filename to restart processing. */
1125 void
1126 cpp_finish (pfile)
1127 cpp_reader *pfile;
1129 /* cpplex.c leaves the final buffer on the stack. This it so that
1130 it returns an unending stream of CPP_EOFs to the client. If we
1131 popped the buffer, we'd dereference a NULL buffer pointer and
1132 segfault. It's nice to allow the client to do worry-free excess
1133 cpp_get_token calls. */
1134 while (pfile->buffer)
1135 _cpp_pop_buffer (pfile);
1137 /* Don't write the deps file if preprocessing has failed. */
1138 if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1139 output_deps (pfile);
1141 /* Report on headers that could use multiple include guards. */
1142 if (CPP_OPTION (pfile, print_include_names))
1143 _cpp_report_missing_guards (pfile);
1146 /* Add a directive to be handled later in the initialization phase. */
1147 static void
1148 new_pending_directive (pend, text, handler)
1149 struct cpp_pending *pend;
1150 const char *text;
1151 cl_directive_handler handler;
1153 struct pending_option *o = (struct pending_option *)
1154 xmalloc (sizeof (struct pending_option));
1156 o->arg = text;
1157 o->next = NULL;
1158 o->handler = handler;
1159 APPEND (pend, directive, o);
1162 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1163 I.e. a const string initializer with parens around it. That is
1164 what N_("string") resolves to, so we make no_* be macros instead. */
1165 #define no_arg N_("argument missing after %s")
1166 #define no_ass N_("assertion missing after %s")
1167 #define no_dir N_("directory name missing after %s")
1168 #define no_fil N_("file name missing after %s")
1169 #define no_mac N_("macro name missing after %s")
1170 #define no_pth N_("path name missing after %s")
1171 #define no_num N_("number missing after %s")
1172 #define no_tgt N_("target missing after %s")
1174 /* This is the list of all command line options, with the leading
1175 "-" removed. It must be sorted in ASCII collating order. */
1176 #define COMMAND_LINE_OPTIONS \
1177 DEF_OPT("$", 0, OPT_dollar) \
1178 DEF_OPT("+", 0, OPT_plus) \
1179 DEF_OPT("-help", 0, OPT__help) \
1180 DEF_OPT("-target-help", 0, OPT_target__help) \
1181 DEF_OPT("-version", 0, OPT__version) \
1182 DEF_OPT("A", no_ass, OPT_A) \
1183 DEF_OPT("C", 0, OPT_C) \
1184 DEF_OPT("D", no_mac, OPT_D) \
1185 DEF_OPT("H", 0, OPT_H) \
1186 DEF_OPT("I", no_dir, OPT_I) \
1187 DEF_OPT("M", 0, OPT_M) \
1188 DEF_OPT("MD", no_fil, OPT_MD) \
1189 DEF_OPT("MF", no_fil, OPT_MF) \
1190 DEF_OPT("MG", 0, OPT_MG) \
1191 DEF_OPT("MM", 0, OPT_MM) \
1192 DEF_OPT("MMD", no_fil, OPT_MMD) \
1193 DEF_OPT("MP", 0, OPT_MP) \
1194 DEF_OPT("MQ", no_tgt, OPT_MQ) \
1195 DEF_OPT("MT", no_tgt, OPT_MT) \
1196 DEF_OPT("P", 0, OPT_P) \
1197 DEF_OPT("U", no_mac, OPT_U) \
1198 DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
1199 DEF_OPT("d", no_arg, OPT_d) \
1200 DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore) \
1201 DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore) \
1202 DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
1203 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
1204 DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
1205 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
1206 DEF_OPT("fshow-column", 0, OPT_fshow_column) \
1207 DEF_OPT("fsigned-char", 0, OPT_fsigned_char) \
1208 DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
1209 DEF_OPT("funsigned-char", 0, OPT_funsigned_char) \
1210 DEF_OPT("h", 0, OPT_h) \
1211 DEF_OPT("idirafter", no_dir, OPT_idirafter) \
1212 DEF_OPT("imacros", no_fil, OPT_imacros) \
1213 DEF_OPT("include", no_fil, OPT_include) \
1214 DEF_OPT("iprefix", no_pth, OPT_iprefix) \
1215 DEF_OPT("isystem", no_dir, OPT_isystem) \
1216 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
1217 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
1218 DEF_OPT("lang-asm", 0, OPT_lang_asm) \
1219 DEF_OPT("lang-c", 0, OPT_lang_c) \
1220 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus) \
1221 DEF_OPT("lang-c89", 0, OPT_lang_c89) \
1222 DEF_OPT("lang-objc", 0, OPT_lang_objc) \
1223 DEF_OPT("lang-objc++", 0, OPT_lang_objcplusplus) \
1224 DEF_OPT("nostdinc", 0, OPT_nostdinc) \
1225 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
1226 DEF_OPT("o", no_fil, OPT_o) \
1227 DEF_OPT("pedantic", 0, OPT_pedantic) \
1228 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
1229 DEF_OPT("remap", 0, OPT_remap) \
1230 DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
1231 DEF_OPT("std=c89", 0, OPT_std_c89) \
1232 DEF_OPT("std=c99", 0, OPT_std_c99) \
1233 DEF_OPT("std=c9x", 0, OPT_std_c9x) \
1234 DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
1235 DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
1236 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
1237 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
1238 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
1239 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
1240 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \
1241 DEF_OPT("trigraphs", 0, OPT_trigraphs) \
1242 DEF_OPT("v", 0, OPT_v) \
1243 DEF_OPT("version", 0, OPT_version) \
1244 DEF_OPT("w", 0, OPT_w)
1246 #define DEF_OPT(text, msg, code) code,
1247 enum opt_code
1249 COMMAND_LINE_OPTIONS
1250 N_OPTS
1252 #undef DEF_OPT
1254 struct cl_option
1256 const char *opt_text;
1257 const char *msg;
1258 size_t opt_len;
1259 enum opt_code opt_code;
1262 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1263 #ifdef HOST_EBCDIC
1264 static struct cl_option cl_options[] =
1265 #else
1266 static const struct cl_option cl_options[] =
1267 #endif
1269 COMMAND_LINE_OPTIONS
1271 #undef DEF_OPT
1272 #undef COMMAND_LINE_OPTIONS
1274 /* Perform a binary search to find which, if any, option the given
1275 command-line matches. Returns its index in the option array,
1276 negative on failure. Complications arise since some options can be
1277 suffixed with an argument, and multiple complete matches can occur,
1278 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
1279 accept options beginning with -W that we do not recognise, but not
1280 to swallow any subsequent command line argument; this is handled as
1281 special cases in cpp_handle_option. */
1282 static int
1283 parse_option (input)
1284 const char *input;
1286 unsigned int md, mn, mx;
1287 size_t opt_len;
1288 int comp;
1290 mn = 0;
1291 mx = N_OPTS;
1293 while (mx > mn)
1295 md = (mn + mx) / 2;
1297 opt_len = cl_options[md].opt_len;
1298 comp = memcmp (input, cl_options[md].opt_text, opt_len);
1300 if (comp > 0)
1301 mn = md + 1;
1302 else if (comp < 0)
1303 mx = md;
1304 else
1306 if (input[opt_len] == '\0')
1307 return md;
1308 /* We were passed more text. If the option takes an argument,
1309 we may match a later option or we may have been passed the
1310 argument. The longest possible option match succeeds.
1311 If the option takes no arguments we have not matched and
1312 continue the search (e.g. input="stdc++" match was "stdc"). */
1313 mn = md + 1;
1314 if (cl_options[md].msg)
1316 /* Scan forwards. If we get an exact match, return it.
1317 Otherwise, return the longest option-accepting match.
1318 This loops no more than twice with current options. */
1319 mx = md;
1320 for (; mn < (unsigned int) N_OPTS; mn++)
1322 opt_len = cl_options[mn].opt_len;
1323 if (memcmp (input, cl_options[mn].opt_text, opt_len))
1324 break;
1325 if (input[opt_len] == '\0')
1326 return mn;
1327 if (cl_options[mn].msg)
1328 mx = mn;
1330 return mx;
1335 return -1;
1338 /* Handle one command-line option in (argc, argv).
1339 Can be called multiple times, to handle multiple sets of options.
1340 If ignore is non-zero, this will ignore unrecognized -W* options.
1341 Returns number of strings consumed. */
1343 cpp_handle_option (pfile, argc, argv, ignore)
1344 cpp_reader *pfile;
1345 int argc;
1346 char **argv;
1347 int ignore;
1349 int i = 0;
1350 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1352 /* Interpret "-" or a non-option as a file name. */
1353 if (argv[i][0] != '-' || argv[i][1] == '\0')
1355 if (CPP_OPTION (pfile, in_fname) == NULL)
1356 CPP_OPTION (pfile, in_fname) = argv[i];
1357 else if (CPP_OPTION (pfile, out_fname) == NULL)
1358 CPP_OPTION (pfile, out_fname) = argv[i];
1359 else
1360 cpp_fatal (pfile, "too many filenames. Type %s --help for usage info",
1361 progname);
1363 else
1365 enum opt_code opt_code;
1366 int opt_index;
1367 const char *arg = 0;
1369 /* Skip over '-'. */
1370 opt_index = parse_option (&argv[i][1]);
1371 if (opt_index < 0)
1372 return i;
1374 opt_code = cl_options[opt_index].opt_code;
1375 if (cl_options[opt_index].msg)
1377 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1379 /* Yuk. Special case for -W as it must not swallow
1380 up any following argument. If this becomes common, add
1381 another field to the cl_options table. */
1382 if (arg[0] == '\0' && opt_code != OPT_W)
1384 arg = argv[++i];
1385 if (!arg)
1387 cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
1388 return argc;
1393 switch (opt_code)
1395 case N_OPTS: /* Shut GCC up. */
1396 break;
1397 case OPT_fleading_underscore:
1398 CPP_OPTION (pfile, user_label_prefix) = "_";
1399 break;
1400 case OPT_fno_leading_underscore:
1401 CPP_OPTION (pfile, user_label_prefix) = "";
1402 break;
1403 case OPT_fno_operator_names:
1404 CPP_OPTION (pfile, operator_names) = 0;
1405 break;
1406 case OPT_fpreprocessed:
1407 CPP_OPTION (pfile, preprocessed) = 1;
1408 break;
1409 case OPT_fno_preprocessed:
1410 CPP_OPTION (pfile, preprocessed) = 0;
1411 break;
1412 case OPT_fshow_column:
1413 CPP_OPTION (pfile, show_column) = 1;
1414 break;
1415 case OPT_fno_show_column:
1416 CPP_OPTION (pfile, show_column) = 0;
1417 break;
1418 case OPT_fsigned_char:
1419 CPP_OPTION (pfile, signed_char) = 1;
1420 break;
1421 case OPT_funsigned_char:
1422 CPP_OPTION (pfile, signed_char) = 0;
1423 break;
1424 case OPT_ftabstop:
1425 /* Silently ignore empty string, non-longs and silly values. */
1426 if (arg[0] != '\0')
1428 char *endptr;
1429 long tabstop = strtol (arg, &endptr, 10);
1430 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1431 CPP_OPTION (pfile, tabstop) = tabstop;
1433 break;
1434 case OPT_w:
1435 CPP_OPTION (pfile, inhibit_warnings) = 1;
1436 break;
1437 case OPT_h:
1438 case OPT__help:
1439 print_help ();
1440 CPP_OPTION (pfile, help_only) = 1;
1441 break;
1442 case OPT_target__help:
1443 /* Print if any target specific options. cpplib has none, but
1444 make sure help_only gets set. */
1445 CPP_OPTION (pfile, help_only) = 1;
1446 break;
1448 /* --version inhibits compilation, -version doesn't. -v means
1449 verbose and -version. Historical reasons, don't ask. */
1450 case OPT__version:
1451 CPP_OPTION (pfile, help_only) = 1;
1452 pfile->print_version = 1;
1453 break;
1454 case OPT_v:
1455 CPP_OPTION (pfile, verbose) = 1;
1456 pfile->print_version = 1;
1457 break;
1458 case OPT_version:
1459 pfile->print_version = 1;
1460 break;
1462 case OPT_C:
1463 CPP_OPTION (pfile, discard_comments) = 0;
1464 break;
1465 case OPT_P:
1466 CPP_OPTION (pfile, no_line_commands) = 1;
1467 break;
1468 case OPT_dollar: /* Don't include $ in identifiers. */
1469 CPP_OPTION (pfile, dollars_in_ident) = 0;
1470 break;
1471 case OPT_H:
1472 CPP_OPTION (pfile, print_include_names) = 1;
1473 break;
1474 case OPT_D:
1475 new_pending_directive (pend, arg, cpp_define);
1476 break;
1477 case OPT_pedantic_errors:
1478 CPP_OPTION (pfile, pedantic_errors) = 1;
1479 /* fall through */
1480 case OPT_pedantic:
1481 CPP_OPTION (pfile, pedantic) = 1;
1482 break;
1483 case OPT_trigraphs:
1484 CPP_OPTION (pfile, trigraphs) = 1;
1485 break;
1486 case OPT_plus:
1487 CPP_OPTION (pfile, cplusplus) = 1;
1488 CPP_OPTION (pfile, cplusplus_comments) = 1;
1489 break;
1490 case OPT_remap:
1491 CPP_OPTION (pfile, remap) = 1;
1492 break;
1493 case OPT_iprefix:
1494 CPP_OPTION (pfile, include_prefix) = arg;
1495 CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1496 break;
1497 case OPT_lang_c:
1498 set_lang (pfile, CLK_GNUC89);
1499 break;
1500 case OPT_lang_cplusplus:
1501 set_lang (pfile, CLK_GNUCXX);
1502 break;
1503 case OPT_lang_objc:
1504 set_lang (pfile, CLK_OBJC);
1505 break;
1506 case OPT_lang_objcplusplus:
1507 set_lang (pfile, CLK_OBJCXX);
1508 break;
1509 case OPT_lang_asm:
1510 set_lang (pfile, CLK_ASM);
1511 break;
1512 case OPT_std_cplusplus98:
1513 set_lang (pfile, CLK_CXX98);
1514 break;
1515 case OPT_std_gnu89:
1516 set_lang (pfile, CLK_GNUC89);
1517 break;
1518 case OPT_std_gnu9x:
1519 case OPT_std_gnu99:
1520 set_lang (pfile, CLK_GNUC99);
1521 break;
1522 case OPT_std_iso9899_199409:
1523 set_lang (pfile, CLK_STDC94);
1524 break;
1525 case OPT_std_iso9899_1990:
1526 case OPT_std_c89:
1527 case OPT_lang_c89:
1528 set_lang (pfile, CLK_STDC89);
1529 break;
1530 case OPT_std_iso9899_199x:
1531 case OPT_std_iso9899_1999:
1532 case OPT_std_c9x:
1533 case OPT_std_c99:
1534 set_lang (pfile, CLK_STDC99);
1535 break;
1536 case OPT_nostdinc:
1537 /* -nostdinc causes no default include directories.
1538 You must specify all include-file directories with -I. */
1539 CPP_OPTION (pfile, no_standard_includes) = 1;
1540 break;
1541 case OPT_nostdincplusplus:
1542 /* -nostdinc++ causes no default C++-specific include directories. */
1543 CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1544 break;
1545 case OPT_o:
1546 if (CPP_OPTION (pfile, out_fname) == NULL)
1547 CPP_OPTION (pfile, out_fname) = arg;
1548 else
1550 cpp_fatal (pfile, "output filename specified twice");
1551 return argc;
1553 break;
1554 case OPT_d:
1555 /* Args to -d specify what parts of macros to dump.
1556 Silently ignore unrecognised options; they may
1557 be aimed at the compiler proper. */
1559 char c;
1561 while ((c = *arg++) != '\0')
1562 switch (c)
1564 case 'M':
1565 CPP_OPTION (pfile, dump_macros) = dump_only;
1566 break;
1567 case 'N':
1568 CPP_OPTION (pfile, dump_macros) = dump_names;
1569 break;
1570 case 'D':
1571 CPP_OPTION (pfile, dump_macros) = dump_definitions;
1572 break;
1573 case 'I':
1574 CPP_OPTION (pfile, dump_includes) = 1;
1575 break;
1578 break;
1580 case OPT_MG:
1581 CPP_OPTION (pfile, print_deps_missing_files) = 1;
1582 break;
1583 case OPT_M:
1584 /* When doing dependencies with -M or -MM, suppress normal
1585 preprocessed output, but still do -dM etc. as software
1586 depends on this. Preprocessed output occurs if -MD, -MMD
1587 or environment var dependency generation is used. */
1588 CPP_OPTION (pfile, print_deps) = 2;
1589 CPP_OPTION (pfile, no_output) = 1;
1590 break;
1591 case OPT_MM:
1592 CPP_OPTION (pfile, print_deps) = 1;
1593 CPP_OPTION (pfile, no_output) = 1;
1594 break;
1595 case OPT_MF:
1596 CPP_OPTION (pfile, deps_file) = arg;
1597 break;
1598 case OPT_MP:
1599 CPP_OPTION (pfile, deps_phony_targets) = 1;
1600 break;
1601 case OPT_MQ:
1602 case OPT_MT:
1603 /* Add a target. -MQ quotes for Make. */
1604 deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
1605 break;
1607 case OPT_MD:
1608 CPP_OPTION (pfile, print_deps) = 2;
1609 CPP_OPTION (pfile, deps_file) = arg;
1610 break;
1611 case OPT_MMD:
1612 CPP_OPTION (pfile, print_deps) = 1;
1613 CPP_OPTION (pfile, deps_file) = arg;
1614 break;
1616 case OPT_A:
1617 if (arg[0] == '-')
1619 /* -A with an argument beginning with '-' acts as
1620 #unassert on whatever immediately follows the '-'.
1621 If "-" is the whole argument, we eliminate all
1622 predefined macros and assertions, including those
1623 that were specified earlier on the command line.
1624 That way we can get rid of any that were passed
1625 automatically in from GCC. */
1627 if (arg[1] == '\0')
1629 free_chain (pend->directive_head);
1630 pend->directive_head = NULL;
1631 pend->directive_tail = NULL;
1633 else
1634 new_pending_directive (pend, arg + 1, cpp_unassert);
1636 else
1637 new_pending_directive (pend, arg, cpp_assert);
1638 break;
1639 case OPT_U:
1640 new_pending_directive (pend, arg, cpp_undef);
1641 break;
1642 case OPT_I: /* Add directory to path for includes. */
1643 if (!strcmp (arg, "-"))
1645 /* -I- means:
1646 Use the preceding -I directories for #include "..."
1647 but not #include <...>.
1648 Don't search the directory of the present file
1649 for #include "...". (Note that -I. -I- is not the same as
1650 the default setup; -I. uses the compiler's working dir.) */
1651 if (! CPP_OPTION (pfile, ignore_srcdir))
1653 pend->quote_head = pend->brack_head;
1654 pend->quote_tail = pend->brack_tail;
1655 pend->brack_head = 0;
1656 pend->brack_tail = 0;
1657 CPP_OPTION (pfile, ignore_srcdir) = 1;
1659 else
1661 cpp_fatal (pfile, "-I- specified twice");
1662 return argc;
1665 else
1666 append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
1667 break;
1668 case OPT_isystem:
1669 /* Add directory to beginning of system include path, as a system
1670 include directory. */
1671 append_include_chain (pfile, xstrdup (arg), SYSTEM, 0);
1672 break;
1673 case OPT_include:
1674 case OPT_imacros:
1676 struct pending_option *o = (struct pending_option *)
1677 xmalloc (sizeof (struct pending_option));
1678 o->arg = arg;
1679 o->next = NULL;
1681 if (opt_code == OPT_include)
1682 APPEND (pend, include, o);
1683 else
1684 APPEND (pend, imacros, o);
1686 break;
1687 case OPT_iwithprefix:
1688 /* Add directory to end of path for includes,
1689 with the default prefix at the front of its name. */
1690 /* fall through */
1691 case OPT_iwithprefixbefore:
1692 /* Add directory to main path for includes,
1693 with the default prefix at the front of its name. */
1695 char *fname;
1696 int len;
1698 len = strlen (arg);
1700 if (CPP_OPTION (pfile, include_prefix) != 0)
1702 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1703 fname = xmalloc (ipl + len + 1);
1704 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1705 memcpy (fname + ipl, arg, len + 1);
1707 else if (cpp_GCC_INCLUDE_DIR_len)
1709 fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
1710 memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
1711 memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
1713 else
1714 fname = xstrdup (arg);
1716 append_include_chain (pfile, fname,
1717 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1719 break;
1720 case OPT_idirafter:
1721 /* Add directory to end of path for includes. */
1722 append_include_chain (pfile, xstrdup (arg), AFTER, 0);
1723 break;
1724 case OPT_W:
1725 /* Silently ignore unrecognised options. */
1726 if (!strcmp (argv[i], "-Wall"))
1728 CPP_OPTION (pfile, warn_trigraphs) = 1;
1729 CPP_OPTION (pfile, warn_comments) = 1;
1731 else if (!strcmp (argv[i], "-Wtraditional"))
1732 CPP_OPTION (pfile, warn_traditional) = 1;
1733 else if (!strcmp (argv[i], "-Wtrigraphs"))
1734 CPP_OPTION (pfile, warn_trigraphs) = 1;
1735 else if (!strcmp (argv[i], "-Wcomment"))
1736 CPP_OPTION (pfile, warn_comments) = 1;
1737 else if (!strcmp (argv[i], "-Wcomments"))
1738 CPP_OPTION (pfile, warn_comments) = 1;
1739 else if (!strcmp (argv[i], "-Wundef"))
1740 CPP_OPTION (pfile, warn_undef) = 1;
1741 else if (!strcmp (argv[i], "-Wimport"))
1742 CPP_OPTION (pfile, warn_import) = 1;
1743 else if (!strcmp (argv[i], "-Werror"))
1744 CPP_OPTION (pfile, warnings_are_errors) = 1;
1745 else if (!strcmp (argv[i], "-Wsystem-headers"))
1746 CPP_OPTION (pfile, warn_system_headers) = 1;
1747 else if (!strcmp (argv[i], "-Wno-traditional"))
1748 CPP_OPTION (pfile, warn_traditional) = 0;
1749 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1750 CPP_OPTION (pfile, warn_trigraphs) = 0;
1751 else if (!strcmp (argv[i], "-Wno-comment"))
1752 CPP_OPTION (pfile, warn_comments) = 0;
1753 else if (!strcmp (argv[i], "-Wno-comments"))
1754 CPP_OPTION (pfile, warn_comments) = 0;
1755 else if (!strcmp (argv[i], "-Wno-undef"))
1756 CPP_OPTION (pfile, warn_undef) = 0;
1757 else if (!strcmp (argv[i], "-Wno-import"))
1758 CPP_OPTION (pfile, warn_import) = 0;
1759 else if (!strcmp (argv[i], "-Wno-error"))
1760 CPP_OPTION (pfile, warnings_are_errors) = 0;
1761 else if (!strcmp (argv[i], "-Wno-system-headers"))
1762 CPP_OPTION (pfile, warn_system_headers) = 0;
1763 else if (! ignore)
1764 return i;
1765 break;
1768 return i + 1;
1771 /* Handle command-line options in (argc, argv).
1772 Can be called multiple times, to handle multiple sets of options.
1773 Returns if an unrecognized option is seen.
1774 Returns number of strings consumed. */
1776 cpp_handle_options (pfile, argc, argv)
1777 cpp_reader *pfile;
1778 int argc;
1779 char **argv;
1781 int i;
1782 int strings_processed;
1784 for (i = 0; i < argc; i += strings_processed)
1786 strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
1787 if (strings_processed == 0)
1788 break;
1791 return i;
1794 /* Extra processing when all options are parsed, after all calls to
1795 cpp_handle_option[s]. Consistency checks etc. */
1796 void
1797 cpp_post_options (pfile)
1798 cpp_reader *pfile;
1800 if (pfile->print_version)
1802 fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
1803 #ifdef TARGET_VERSION
1804 TARGET_VERSION;
1805 #endif
1806 fputc ('\n', stderr);
1809 /* Canonicalize in_fname and out_fname. We guarantee they are not
1810 NULL, and that the empty string represents stdin / stdout. */
1811 if (CPP_OPTION (pfile, in_fname) == NULL
1812 || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
1813 CPP_OPTION (pfile, in_fname) = "";
1815 if (CPP_OPTION (pfile, out_fname) == NULL
1816 || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
1817 CPP_OPTION (pfile, out_fname) = "";
1819 /* -Wtraditional is not useful in C++ mode. */
1820 if (CPP_OPTION (pfile, cplusplus))
1821 CPP_OPTION (pfile, warn_traditional) = 0;
1823 /* Set this if it hasn't been set already. */
1824 if (CPP_OPTION (pfile, user_label_prefix) == NULL)
1825 CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
1827 /* Permanently disable macro expansion if we are rescanning
1828 preprocessed text. */
1829 if (CPP_OPTION (pfile, preprocessed))
1830 pfile->state.prevent_expansion = 1;
1832 /* -dM makes no normal output. This is set here so that -dM -dD
1833 works as expected. */
1834 if (CPP_OPTION (pfile, dump_macros) == dump_only)
1835 CPP_OPTION (pfile, no_output) = 1;
1837 /* Disable -dD, -dN and -dI if we should make no normal output
1838 (such as with -M). Allow -M -dM since some software relies on
1839 this. */
1840 if (CPP_OPTION (pfile, no_output))
1842 if (CPP_OPTION (pfile, dump_macros) != dump_only)
1843 CPP_OPTION (pfile, dump_macros) = dump_none;
1844 CPP_OPTION (pfile, dump_includes) = 0;
1847 /* We need to do this after option processing and before
1848 cpp_start_read, as cppmain.c relies on the options->no_output to
1849 set its callbacks correctly before calling cpp_start_read. */
1850 init_dependency_output (pfile);
1852 /* After checking the environment variables, check if -M or -MM has
1853 not been specified, but other -M options have. */
1854 if (CPP_OPTION (pfile, print_deps) == 0 &&
1855 (CPP_OPTION (pfile, print_deps_missing_files)
1856 || CPP_OPTION (pfile, deps_file)
1857 || CPP_OPTION (pfile, deps_phony_targets)))
1858 cpp_fatal (pfile, "you must additionally specify either -M or -MM");
1861 /* Set up dependency-file output. On exit, if print_deps is non-zero
1862 then deps_file is not NULL; stdout is the empty string. */
1863 static void
1864 init_dependency_output (pfile)
1865 cpp_reader *pfile;
1867 char *spec, *s, *output_file;
1869 /* Either of two environment variables can specify output of deps.
1870 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
1871 where OUTPUT_FILE is the file to write deps info to
1872 and DEPS_TARGET is the target to mention in the deps. */
1874 if (CPP_OPTION (pfile, print_deps) == 0)
1876 spec = getenv ("DEPENDENCIES_OUTPUT");
1877 if (spec)
1878 CPP_OPTION (pfile, print_deps) = 1;
1879 else
1881 spec = getenv ("SUNPRO_DEPENDENCIES");
1882 if (spec)
1883 CPP_OPTION (pfile, print_deps) = 2;
1884 else
1885 return;
1888 /* Find the space before the DEPS_TARGET, if there is one. */
1889 s = strchr (spec, ' ');
1890 if (s)
1892 /* Let the caller perform MAKE quoting. */
1893 deps_add_target (pfile->deps, s + 1, 0);
1894 output_file = (char *) xmalloc (s - spec + 1);
1895 memcpy (output_file, spec, s - spec);
1896 output_file[s - spec] = 0;
1898 else
1899 output_file = spec;
1901 /* Command line -MF overrides environment variables and default. */
1902 if (CPP_OPTION (pfile, deps_file) == 0)
1903 CPP_OPTION (pfile, deps_file) = output_file;
1905 CPP_OPTION (pfile, print_deps_append) = 1;
1907 else if (CPP_OPTION (pfile, deps_file) == 0)
1908 /* If -M or -MM was seen without -MF, default output to wherever
1909 was specified with -o. out_fname is non-NULL here. */
1910 CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
1913 /* Handle --help output. */
1914 static void
1915 print_help ()
1917 /* To keep the lines from getting too long for some compilers, limit
1918 to about 500 characters (6 lines) per chunk. */
1919 fputs (_("\
1920 Switches:\n\
1921 -include <file> Include the contents of <file> before other files\n\
1922 -imacros <file> Accept definition of macros in <file>\n\
1923 -iprefix <path> Specify <path> as a prefix for next two options\n\
1924 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1925 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1926 -isystem <dir> Add <dir> to the start of the system include path\n\
1927 "), stdout);
1928 fputs (_("\
1929 -idirafter <dir> Add <dir> to the end of the system include path\n\
1930 -I <dir> Add <dir> to the end of the main include path\n\
1931 -I- Fine-grained include path control; see info docs\n\
1932 -nostdinc Do not search system include directories\n\
1933 (dirs specified with -isystem will still be used)\n\
1934 -nostdinc++ Do not search system include directories for C++\n\
1935 -o <file> Put output into <file>\n\
1936 "), stdout);
1937 fputs (_("\
1938 -pedantic Issue all warnings demanded by strict ISO C\n\
1939 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1940 -trigraphs Support ISO C trigraphs\n\
1941 -lang-c Assume that the input sources are in C\n\
1942 -lang-c89 Assume that the input sources are in C89\n\
1943 "), stdout);
1944 fputs (_("\
1945 -lang-c++ Assume that the input sources are in C++\n\
1946 -lang-objc Assume that the input sources are in ObjectiveC\n\
1947 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1948 -lang-asm Assume that the input sources are in assembler\n\
1949 "), stdout);
1950 fputs (_("\
1951 -std=<std name> Specify the conformance standard; one of:\n\
1952 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1953 iso9899:199409, iso9899:1999\n\
1954 -+ Allow parsing of C++ style features\n\
1955 -w Inhibit warning messages\n\
1956 -Wtrigraphs Warn if trigraphs are encountered\n\
1957 -Wno-trigraphs Do not warn about trigraphs\n\
1958 -Wcomment{s} Warn if one comment starts inside another\n\
1959 "), stdout);
1960 fputs (_("\
1961 -Wno-comment{s} Do not warn about comments\n\
1962 -Wtraditional Warn about features not present in traditional C\n\
1963 -Wno-traditional Do not warn about traditional C\n\
1964 -Wundef Warn if an undefined macro is used by #if\n\
1965 -Wno-undef Do not warn about testing undefined macros\n\
1966 -Wimport Warn about the use of the #import directive\n\
1967 "), stdout);
1968 fputs (_("\
1969 -Wno-import Do not warn about the use of #import\n\
1970 -Werror Treat all warnings as errors\n\
1971 -Wno-error Do not treat warnings as errors\n\
1972 -Wsystem-headers Do not suppress warnings from system headers\n\
1973 -Wno-system-headers Suppress warnings from system headers\n\
1974 -Wall Enable all preprocessor warnings\n\
1975 "), stdout);
1976 fputs (_("\
1977 -M Generate make dependencies\n\
1978 -MM As -M, but ignore system header files\n\
1979 -MD Generate make dependencies and compile\n\
1980 -MMD As -MD, but ignore system header files\n\
1981 -MF <file> Write dependency output to the given file\n\
1982 -MG Treat missing header file as generated files\n\
1983 "), stdout);
1984 fputs (_("\
1985 -MP Generate phony targets for all headers\n\
1986 -MQ <target> Add a MAKE-quoted target\n\
1987 -MT <target> Add an unquoted target\n\
1988 "), stdout);
1989 fputs (_("\
1990 -D<macro> Define a <macro> with string '1' as its value\n\
1991 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1992 -A<question>=<answer> Assert the <answer> to <question>\n\
1993 -A-<question>=<answer> Disable the <answer> to <question>\n\
1994 -U<macro> Undefine <macro> \n\
1995 -v Display the version number\n\
1996 "), stdout);
1997 fputs (_("\
1998 -H Print the name of header files as they are used\n\
1999 -C Do not discard comments\n\
2000 -dM Display a list of macro definitions active at end\n\
2001 -dD Preserve macro definitions in output\n\
2002 -dN As -dD except that only the names are preserved\n\
2003 -dI Include #include directives in the output\n\
2004 "), stdout);
2005 fputs (_("\
2006 -fpreprocessed Treat the input file as already preprocessed\n\
2007 -ftabstop=<number> Distance between tab stops for column reporting\n\
2008 -P Do not generate #line directives\n\
2009 -$ Do not allow '$' in identifiers\n\
2010 -remap Remap file names when including files\n\
2011 --version Display version information\n\
2012 -h or --help Display this information\n\
2013 "), stdout);