* expr.c (expand_expr) [MULT_EXPR]: Do not apply distributive law
[official-gcc.git] / gcc / cppinit.c
blob70fc828dd2bf50d97b130ef09f3339b85c6fd5e8
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 append_include_chain PARAMS ((cpp_reader *,
103 char *, int, int));
104 static struct search_path * remove_dup_dir PARAMS ((cpp_reader *,
105 struct search_path *));
106 static struct search_path * remove_dup_dirs PARAMS ((cpp_reader *,
107 struct search_path *));
108 static void merge_include_chains PARAMS ((cpp_reader *));
109 static bool push_include PARAMS ((cpp_reader *,
110 struct pending_option *));
111 static void free_chain PARAMS ((struct pending_option *));
112 static void set_lang PARAMS ((cpp_reader *, enum c_lang));
113 static void init_dependency_output PARAMS ((cpp_reader *));
114 static void init_standard_includes PARAMS ((cpp_reader *));
115 static void read_original_filename PARAMS ((cpp_reader *));
116 static void new_pending_directive PARAMS ((struct cpp_pending *,
117 const char *,
118 cl_directive_handler));
119 static void output_deps PARAMS ((cpp_reader *));
120 static int parse_option PARAMS ((const char *));
122 /* Fourth argument to append_include_chain: chain to use.
123 Note it's never asked to append to the quote chain. */
124 enum { BRACKET = 0, SYSTEM, AFTER };
126 /* If we have designated initializers (GCC >2.7) these tables can be
127 initialized, constant data. Otherwise, they have to be filled in at
128 runtime. */
129 #if HAVE_DESIGNATED_INITIALIZERS
131 #define init_trigraph_map() /* Nothing. */
132 #define TRIGRAPH_MAP \
133 __extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
135 #define END };
136 #define s(p, v) [p] = v,
138 #else
140 #define TRIGRAPH_MAP U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
141 static void init_trigraph_map PARAMS ((void)) { \
142 unsigned char *x = _cpp_trigraph_map;
144 #define END }
145 #define s(p, v) x[p] = v;
147 #endif
149 TRIGRAPH_MAP
150 s('=', '#') s(')', ']') s('!', '|')
151 s('(', '[') s('\'', '^') s('>', '}')
152 s('/', '\\') s('<', '{') s('-', '~')
155 #undef s
156 #undef END
157 #undef TRIGRAPH_MAP
159 /* Given a colon-separated list of file names PATH,
160 add all the names to the search path for include files. */
161 static void
162 path_include (pfile, list, path)
163 cpp_reader *pfile;
164 char *list;
165 int path;
167 char *p, *q, *name;
169 p = list;
173 /* Find the end of this name. */
174 q = p;
175 while (*q != 0 && *q != PATH_SEPARATOR) q++;
176 if (q == p)
178 /* An empty name in the path stands for the current directory. */
179 name = (char *) xmalloc (2);
180 name[0] = '.';
181 name[1] = 0;
183 else
185 /* Otherwise use the directory that is named. */
186 name = (char *) xmalloc (q - p + 1);
187 memcpy (name, p, q - p);
188 name[q - p] = 0;
191 append_include_chain (pfile, name, path, 0);
193 /* Advance past this name. */
194 if (*q == 0)
195 break;
196 p = q + 1;
198 while (1);
201 /* Append DIR to include path PATH. DIR must be allocated on the
202 heap; this routine takes responsibility for freeing it. CXX_AWARE
203 is non-zero if the header contains extern "C" guards for C++,
204 otherwise it is zero. */
205 static void
206 append_include_chain (pfile, dir, path, cxx_aware)
207 cpp_reader *pfile;
208 char *dir;
209 int path;
210 int cxx_aware ATTRIBUTE_UNUSED;
212 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
213 struct search_path *new;
214 struct stat st;
215 unsigned int len;
217 if (*dir == '\0')
219 free (dir);
220 dir = xstrdup (".");
222 _cpp_simplify_pathname (dir);
224 if (stat (dir, &st))
226 /* Dirs that don't exist are silently ignored. */
227 if (errno != ENOENT)
228 cpp_notice_from_errno (pfile, dir);
229 else if (CPP_OPTION (pfile, verbose))
230 fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
231 free (dir);
232 return;
235 if (!S_ISDIR (st.st_mode))
237 cpp_notice (pfile, "%s: Not a directory", dir);
238 free (dir);
239 return;
242 len = strlen (dir);
243 if (len > pfile->max_include_len)
244 pfile->max_include_len = len;
246 new = (struct search_path *) xmalloc (sizeof (struct search_path));
247 new->name = dir;
248 new->len = len;
249 INO_T_COPY (new->ino, st.st_ino);
250 new->dev = st.st_dev;
251 /* Both systm and after include file lists should be treated as system
252 include files since these two lists are really just a concatenation
253 of one "system" list. */
254 if (path == SYSTEM || path == AFTER)
255 #ifdef NO_IMPLICIT_EXTERN_C
256 new->sysp = 1;
257 #else
258 new->sysp = cxx_aware ? 1 : 2;
259 #endif
260 else
261 new->sysp = 0;
262 new->name_map = NULL;
263 new->next = NULL;
265 switch (path)
267 case BRACKET: APPEND (pend, brack, new); break;
268 case SYSTEM: APPEND (pend, systm, new); break;
269 case AFTER: APPEND (pend, after, new); break;
273 /* Handle a duplicated include path. PREV is the link in the chain
274 before the duplicate. The duplicate is removed from the chain and
275 freed. Returns PREV. */
276 static struct search_path *
277 remove_dup_dir (pfile, prev)
278 cpp_reader *pfile;
279 struct search_path *prev;
281 struct search_path *cur = prev->next;
283 if (CPP_OPTION (pfile, verbose))
284 fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), cur->name);
286 prev->next = cur->next;
287 free ((PTR) cur->name);
288 free (cur);
290 return prev;
293 /* Remove duplicate directories from a chain. Returns the tail of the
294 chain, or NULL if the chain is empty. This algorithm is quadratic
295 in the number of -I switches, which is acceptable since there
296 aren't usually that many of them. */
297 static struct search_path *
298 remove_dup_dirs (pfile, head)
299 cpp_reader *pfile;
300 struct search_path *head;
302 struct search_path *prev = NULL, *cur, *other;
304 for (cur = head; cur; cur = cur->next)
306 for (other = head; other != cur; other = other->next)
307 if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
309 if (cur->sysp && !other->sysp)
311 cpp_warning (pfile,
312 "changing search order for system directory \"%s\"",
313 cur->name);
314 if (strcmp (cur->name, other->name))
315 cpp_warning (pfile,
316 " as it is the same as non-system directory \"%s\"",
317 other->name);
318 else
319 cpp_warning (pfile,
320 " as it has already been specified as a non-system directory");
322 cur = remove_dup_dir (pfile, prev);
323 break;
325 prev = cur;
328 return prev;
331 /* Merge the four include chains together in the order quote, bracket,
332 system, after. Remove duplicate dirs (as determined by
333 INO_T_EQ()). The system_include and after_include chains are never
334 referred to again after this function; all access is through the
335 bracket_include path. */
336 static void
337 merge_include_chains (pfile)
338 cpp_reader *pfile;
340 struct search_path *quote, *brack, *systm, *qtail;
342 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
344 quote = pend->quote_head;
345 brack = pend->brack_head;
346 systm = pend->systm_head;
347 qtail = pend->quote_tail;
349 /* Paste together bracket, system, and after include chains. */
350 if (systm)
351 pend->systm_tail->next = pend->after_head;
352 else
353 systm = pend->after_head;
355 if (brack)
356 pend->brack_tail->next = systm;
357 else
358 brack = systm;
360 /* This is a bit tricky. First we drop dupes from the quote-include
361 list. Then we drop dupes from the bracket-include list.
362 Finally, if qtail and brack are the same directory, we cut out
363 brack and move brack up to point to qtail.
365 We can't just merge the lists and then uniquify them because
366 then we may lose directories from the <> search path that should
367 be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
368 safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
369 -Ibar -I- -Ifoo -Iquux. */
371 remove_dup_dirs (pfile, brack);
372 qtail = remove_dup_dirs (pfile, quote);
374 if (quote)
376 qtail->next = brack;
378 /* If brack == qtail, remove brack as it's simpler. */
379 if (brack && INO_T_EQ (qtail->ino, brack->ino)
380 && qtail->dev == brack->dev)
381 brack = remove_dup_dir (pfile, qtail);
383 else
384 quote = brack;
386 CPP_OPTION (pfile, quote_include) = quote;
387 CPP_OPTION (pfile, bracket_include) = brack;
390 /* A set of booleans indicating what CPP features each source language
391 requires. */
392 struct lang_flags
394 char c99;
395 char objc;
396 char cplusplus;
397 char extended_numbers;
398 char trigraphs;
399 char dollars_in_ident;
400 char cplusplus_comments;
401 char digraphs;
404 /* ??? Enable $ in identifiers in assembly? */
405 static const struct lang_flags lang_defaults[] =
406 { /* c99 objc c++ xnum trig dollar c++comm digr */
407 /* GNUC89 */ { 0, 0, 0, 1, 0, 1, 1, 1 },
408 /* GNUC99 */ { 1, 0, 0, 1, 0, 1, 1, 1 },
409 /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0 },
410 /* STDC94 */ { 0, 0, 0, 0, 1, 0, 0, 1 },
411 /* STDC99 */ { 1, 0, 0, 1, 1, 0, 1, 1 },
412 /* GNUCXX */ { 0, 0, 1, 1, 0, 1, 1, 1 },
413 /* CXX98 */ { 0, 0, 1, 1, 1, 0, 1, 1 },
414 /* OBJC */ { 0, 1, 0, 1, 0, 1, 1, 1 },
415 /* OBJCXX */ { 0, 1, 1, 1, 0, 1, 1, 1 },
416 /* ASM */ { 0, 0, 0, 1, 0, 0, 1, 0 }
419 /* Sets internal flags correctly for a given language. */
420 static void
421 set_lang (pfile, lang)
422 cpp_reader *pfile;
423 enum c_lang lang;
425 const struct lang_flags *l = &lang_defaults[(int) lang];
427 CPP_OPTION (pfile, lang) = lang;
429 CPP_OPTION (pfile, c99) = l->c99;
430 CPP_OPTION (pfile, objc) = l->objc;
431 CPP_OPTION (pfile, cplusplus) = l->cplusplus;
432 CPP_OPTION (pfile, extended_numbers) = l->extended_numbers;
433 CPP_OPTION (pfile, trigraphs) = l->trigraphs;
434 CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident;
435 CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments;
436 CPP_OPTION (pfile, digraphs) = l->digraphs;
439 #ifdef HOST_EBCDIC
440 static int opt_comp PARAMS ((const void *, const void *));
442 /* Run-time sorting of options array. */
443 static int
444 opt_comp (p1, p2)
445 const void *p1, *p2;
447 return strcmp (((struct cl_option *) p1)->opt_text,
448 ((struct cl_option *) p2)->opt_text);
450 #endif
452 /* init initializes library global state. It might not need to
453 do anything depending on the platform and compiler. */
454 static void
455 init_library ()
457 static int initialized = 0;
459 if (! initialized)
461 initialized = 1;
463 #ifdef HOST_EBCDIC
464 /* For non-ASCII hosts, the cl_options array needs to be sorted at
465 runtime. */
466 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
467 #endif
469 /* Set up the trigraph map. This doesn't need to do anything if
470 we were compiled with a compiler that supports C99 designated
471 initializers. */
472 init_trigraph_map ();
476 /* Initialize a cpp_reader structure. */
477 cpp_reader *
478 cpp_create_reader (lang)
479 enum c_lang lang;
481 cpp_reader *pfile;
483 /* Initialise this instance of the library if it hasn't been already. */
484 init_library ();
486 pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
488 set_lang (pfile, lang);
489 CPP_OPTION (pfile, warn_import) = 1;
490 CPP_OPTION (pfile, discard_comments) = 1;
491 CPP_OPTION (pfile, show_column) = 1;
492 CPP_OPTION (pfile, tabstop) = 8;
493 CPP_OPTION (pfile, operator_names) = 1;
494 #if DEFAULT_SIGNED_CHAR
495 CPP_OPTION (pfile, signed_char) = 1;
496 #else
497 CPP_OPTION (pfile, signed_char) = 0;
498 #endif
500 CPP_OPTION (pfile, pending) =
501 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
503 /* It's simplest to just create this struct whether or not it will
504 be needed. */
505 pfile->deps = deps_init ();
507 /* Initialise the line map. Start at logical line 1, so we can use
508 a line number of zero for special states. */
509 init_line_maps (&pfile->line_maps);
510 pfile->line = 1;
512 /* Initialize lexer state. */
513 pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
515 /* Set up static tokens. */
516 pfile->date.type = CPP_EOF;
517 pfile->avoid_paste.type = CPP_PADDING;
518 pfile->avoid_paste.val.source = NULL;
519 pfile->eof.type = CPP_EOF;
520 pfile->eof.flags = 0;
522 /* Create a token buffer for the lexer. */
523 _cpp_init_tokenrun (&pfile->base_run, 250);
524 pfile->cur_run = &pfile->base_run;
525 pfile->cur_token = pfile->base_run.base;
527 /* Initialise the base context. */
528 pfile->context = &pfile->base_context;
529 pfile->base_context.macro = 0;
530 pfile->base_context.prev = pfile->base_context.next = 0;
532 /* Aligned and unaligned storage. */
533 pfile->a_buff = _cpp_get_buff (pfile, 0);
534 pfile->u_buff = _cpp_get_buff (pfile, 0);
536 /* Initialise the buffer obstack. */
537 gcc_obstack_init (&pfile->buffer_ob);
539 _cpp_init_includes (pfile);
541 return pfile;
544 /* Free resources used by PFILE. Accessing PFILE after this function
545 returns leads to undefined behaviour. Returns the error count. */
547 cpp_destroy (pfile)
548 cpp_reader *pfile;
550 int result;
551 struct search_path *dir, *dirn;
552 cpp_context *context, *contextn;
553 tokenrun *run, *runn;
555 while (CPP_BUFFER (pfile) != NULL)
556 _cpp_pop_buffer (pfile);
558 if (pfile->macro_buffer)
560 free ((PTR) pfile->macro_buffer);
561 pfile->macro_buffer = NULL;
562 pfile->macro_buffer_len = 0;
565 deps_free (pfile->deps);
566 obstack_free (&pfile->buffer_ob, 0);
568 _cpp_destroy_hashtable (pfile);
569 _cpp_cleanup_includes (pfile);
571 _cpp_free_buff (pfile->a_buff);
572 _cpp_free_buff (pfile->u_buff);
573 _cpp_free_buff (pfile->free_buffs);
575 for (run = &pfile->base_run; run; run = runn)
577 runn = run->next;
578 free (run->base);
579 if (run != &pfile->base_run)
580 free (run);
583 for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
585 dirn = dir->next;
586 free ((PTR) dir->name);
587 free (dir);
590 for (context = pfile->base_context.next; context; context = contextn)
592 contextn = context->next;
593 free (context);
596 free_line_maps (&pfile->line_maps);
598 result = pfile->errors;
599 free (pfile);
601 return result;
605 /* This structure defines one built-in identifier. A node will be
606 entered in the hash table under the name NAME, with value VALUE (if
607 any). If flags has OPERATOR, the node's operator field is used; if
608 flags has BUILTIN the node's builtin field is used. Macros that are
609 known at build time should not be flagged BUILTIN, as then they do
610 not appear in macro dumps with e.g. -dM or -dD.
612 Two values are not compile time constants, so we tag
613 them in the FLAGS field instead:
614 VERS value is the global version_string, quoted
615 ULP value is the global user_label_prefix
617 Also, macros with CPLUS set in the flags field are entered only for C++. */
618 struct builtin
620 const U_CHAR *name;
621 const char *value;
622 unsigned char builtin;
623 unsigned char operator;
624 unsigned short flags;
625 unsigned short len;
627 #define VERS 0x01
628 #define ULP 0x02
629 #define CPLUS 0x04
630 #define BUILTIN 0x08
631 #define OPERATOR 0x10
633 #define B(n, t) { U n, 0, t, 0, BUILTIN, sizeof n - 1 }
634 #define C(n, v) { U n, v, 0, 0, 0, sizeof n - 1 }
635 #define X(n, f) { U n, 0, 0, 0, f, sizeof n - 1 }
636 #define O(n, c, f) { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 }
637 static const struct builtin builtin_array[] =
639 B("__TIME__", BT_TIME),
640 B("__DATE__", BT_DATE),
641 B("__FILE__", BT_FILE),
642 B("__BASE_FILE__", BT_BASE_FILE),
643 B("__LINE__", BT_SPECLINE),
644 B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
645 B("_Pragma", BT_PRAGMA),
647 X("__VERSION__", VERS),
648 X("__USER_LABEL_PREFIX__", ULP),
649 C("__REGISTER_PREFIX__", REGISTER_PREFIX),
650 C("__HAVE_BUILTIN_SETJMP__", "1"),
651 #if USING_SJLJ_EXCEPTIONS
652 /* libgcc needs to know this. */
653 C("__USING_SJLJ_EXCEPTIONS__","1"),
654 #endif
655 #ifndef NO_BUILTIN_SIZE_TYPE
656 C("__SIZE_TYPE__", SIZE_TYPE),
657 #endif
658 #ifndef NO_BUILTIN_PTRDIFF_TYPE
659 C("__PTRDIFF_TYPE__", PTRDIFF_TYPE),
660 #endif
661 #ifndef NO_BUILTIN_WCHAR_TYPE
662 C("__WCHAR_TYPE__", WCHAR_TYPE),
663 #endif
664 #ifndef NO_BUILTIN_WINT_TYPE
665 C("__WINT_TYPE__", WINT_TYPE),
666 #endif
667 #ifdef STDC_0_IN_SYSTEM_HEADERS
668 B("__STDC__", BT_STDC),
669 #else
670 C("__STDC__", "1"),
671 #endif
673 /* Named operators known to the preprocessor. These cannot be #defined
674 and always have their stated meaning. They are treated like normal
675 identifiers except for the type code and the meaning. Most of them
676 are only for C++ (but see iso646.h). */
677 O("and", CPP_AND_AND, CPLUS),
678 O("and_eq", CPP_AND_EQ, CPLUS),
679 O("bitand", CPP_AND, CPLUS),
680 O("bitor", CPP_OR, CPLUS),
681 O("compl", CPP_COMPL, CPLUS),
682 O("not", CPP_NOT, CPLUS),
683 O("not_eq", CPP_NOT_EQ, CPLUS),
684 O("or", CPP_OR_OR, CPLUS),
685 O("or_eq", CPP_OR_EQ, CPLUS),
686 O("xor", CPP_XOR, CPLUS),
687 O("xor_eq", CPP_XOR_EQ, CPLUS)
689 #undef B
690 #undef C
691 #undef X
692 #undef O
693 #define builtin_array_end \
694 builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
696 /* Subroutine of cpp_read_main_file; reads the builtins table above and
697 enters them, and language-specific macros, into the hash table. */
698 static void
699 init_builtins (pfile)
700 cpp_reader *pfile;
702 const struct builtin *b;
704 for(b = builtin_array; b < builtin_array_end; b++)
706 if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus))
707 continue;
709 if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names))
710 continue;
712 if (b->flags & (OPERATOR | BUILTIN))
714 cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
715 if (b->flags & OPERATOR)
717 hp->flags |= NODE_OPERATOR;
718 hp->value.operator = b->operator;
720 else
722 hp->type = NT_MACRO;
723 hp->flags |= NODE_BUILTIN | NODE_WARN;
724 hp->value.builtin = b->builtin;
727 else /* A standard macro of some kind. */
729 const char *val;
730 char *str;
732 if (b->flags & VERS)
734 /* Allocate enough space for 'name "value"\n\0'. */
735 str = alloca (b->len + strlen (version_string) + 5);
736 sprintf (str, "%s \"%s\"\n", b->name, version_string);
738 else
740 if (b->flags & ULP)
741 val = CPP_OPTION (pfile, user_label_prefix);
742 else
743 val = b->value;
745 /* Allocate enough space for "name value\n\0". */
746 str = alloca (b->len + strlen (val) + 3);
747 sprintf(str, "%s %s\n", b->name, val);
750 _cpp_define_builtin (pfile, str);
754 if (CPP_OPTION (pfile, cplusplus))
756 _cpp_define_builtin (pfile, "__cplusplus 1");
757 if (SUPPORTS_ONE_ONLY)
758 _cpp_define_builtin (pfile, "__GXX_WEAK__ 1");
759 else
760 _cpp_define_builtin (pfile, "__GXX_WEAK__ 0");
762 if (CPP_OPTION (pfile, objc))
763 _cpp_define_builtin (pfile, "__OBJC__ 1");
765 if (CPP_OPTION (pfile, lang) == CLK_STDC94)
766 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
767 else if (CPP_OPTION (pfile, c99))
768 _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
770 if (CPP_OPTION (pfile, signed_char) == 0)
771 _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
773 if (CPP_OPTION (pfile, lang) == CLK_STDC89
774 || CPP_OPTION (pfile, lang) == CLK_STDC94
775 || CPP_OPTION (pfile, lang) == CLK_STDC99)
776 _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
777 else if (CPP_OPTION (pfile, lang) == CLK_ASM)
778 _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
780 #undef BUILTIN
781 #undef OPERATOR
782 #undef VERS
783 #undef ULP
784 #undef CPLUS
785 #undef builtin_array_end
787 /* And another subroutine. This one sets up the standard include path. */
788 static void
789 init_standard_includes (pfile)
790 cpp_reader *pfile;
792 char *path;
793 const struct default_include *p;
794 const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
796 /* Several environment variables may add to the include search path.
797 CPATH specifies an additional list of directories to be searched
798 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
799 etc. specify an additional list of directories to be searched as
800 if specified with -isystem, for the language indicated. */
802 GET_ENV_PATH_LIST (path, "CPATH");
803 if (path != 0 && *path != 0)
804 path_include (pfile, path, BRACKET);
806 switch ((CPP_OPTION (pfile, objc) << 1) + CPP_OPTION (pfile, cplusplus))
808 case 0:
809 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
810 break;
811 case 1:
812 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
813 break;
814 case 2:
815 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
816 break;
817 case 3:
818 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
819 break;
821 if (path != 0 && *path != 0)
822 path_include (pfile, path, SYSTEM);
824 /* Search "translated" versions of GNU directories.
825 These have /usr/local/lib/gcc... replaced by specd_prefix. */
826 if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
828 /* Remove the `include' from /usr/local/lib/gcc.../include.
829 GCC_INCLUDE_DIR will always end in /include. */
830 int default_len = cpp_GCC_INCLUDE_DIR_len;
831 char *default_prefix = (char *) alloca (default_len + 1);
832 int specd_len = strlen (specd_prefix);
834 memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
835 default_prefix[default_len] = '\0';
837 for (p = cpp_include_defaults; p->fname; p++)
839 /* Some standard dirs are only for C++. */
840 if (!p->cplusplus
841 || (CPP_OPTION (pfile, cplusplus)
842 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
844 /* Does this dir start with the prefix? */
845 if (!memcmp (p->fname, default_prefix, default_len))
847 /* Yes; change prefix and add to search list. */
848 int flen = strlen (p->fname);
849 int this_len = specd_len + flen - default_len;
850 char *str = (char *) xmalloc (this_len + 1);
851 memcpy (str, specd_prefix, specd_len);
852 memcpy (str + specd_len,
853 p->fname + default_len,
854 flen - default_len + 1);
856 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
862 /* Search ordinary names for GNU include directories. */
863 for (p = cpp_include_defaults; p->fname; p++)
865 /* Some standard dirs are only for C++. */
866 if (!p->cplusplus
867 || (CPP_OPTION (pfile, cplusplus)
868 && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
870 char *str = update_path (p->fname, p->component);
871 append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
876 /* Pushes a command line -imacro and -include file indicated by P onto
877 the buffer stack. Returns non-zero if successful. */
878 static bool
879 push_include (pfile, p)
880 cpp_reader *pfile;
881 struct pending_option *p;
883 cpp_token header;
885 /* Later: maybe update this to use the #include "" search path
886 if cpp_read_file fails. */
887 header.type = CPP_STRING;
888 header.val.str.text = (const unsigned char *) p->arg;
889 header.val.str.len = strlen (p->arg);
890 /* Make the command line directive take up a line. */
891 pfile->line++;
893 return _cpp_execute_include (pfile, &header, IT_CMDLINE);
896 /* Frees a pending_option chain. */
897 static void
898 free_chain (head)
899 struct pending_option *head;
901 struct pending_option *next;
903 while (head)
905 next = head->next;
906 free (head);
907 head = next;
911 /* This is called after options have been parsed, and partially
912 processed. Setup for processing input from the file named FNAME,
913 or stdin if it is the empty string. Return the original filename
914 on success (e.g. foo.i->foo.c), or NULL on failure. */
915 const char *
916 cpp_read_main_file (pfile, fname, table)
917 cpp_reader *pfile;
918 const char *fname;
919 hash_table *table;
921 /* The front ends don't set up the hash table until they have
922 finished processing the command line options, so initializing the
923 hashtable is deferred until now. */
924 _cpp_init_hashtable (pfile, table);
926 /* Set up the include search path now. */
927 if (! CPP_OPTION (pfile, no_standard_includes))
928 init_standard_includes (pfile);
930 merge_include_chains (pfile);
932 /* With -v, print the list of dirs to search. */
933 if (CPP_OPTION (pfile, verbose))
935 struct search_path *l;
936 fprintf (stderr, _("#include \"...\" search starts here:\n"));
937 for (l = CPP_OPTION (pfile, quote_include); l; l = l->next)
939 if (l == CPP_OPTION (pfile, bracket_include))
940 fprintf (stderr, _("#include <...> search starts here:\n"));
941 fprintf (stderr, " %s\n", l->name);
943 fprintf (stderr, _("End of search list.\n"));
946 if (CPP_OPTION (pfile, print_deps))
947 /* Set the default target (if there is none already). */
948 deps_add_default_target (pfile->deps, fname);
950 /* Open the main input file. */
951 if (!_cpp_read_file (pfile, fname))
952 return NULL;
954 /* Set this after cpp_post_options so the client can change the
955 option if it wishes, and after stacking the main file so we don't
956 trace the main file. */
957 pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
959 /* For foo.i, read the original filename foo.c now, for the benefit
960 of the front ends. */
961 if (CPP_OPTION (pfile, preprocessed))
962 read_original_filename (pfile);
964 return pfile->map->to_file;
967 /* For preprocessed files, if the first tokens are of the form # NUM.
968 handle the directive so we know the original file name. This will
969 generate file_change callbacks, which the front ends must handle
970 appropriately given their state of initialization. */
971 static void
972 read_original_filename (pfile)
973 cpp_reader *pfile;
975 const cpp_token *token, *token1;
977 /* Lex ahead; if the first tokens are of the form # NUM, then
978 process the directive, otherwise back up. */
979 token = _cpp_lex_direct (pfile);
980 if (token->type == CPP_HASH)
982 token1 = _cpp_lex_direct (pfile);
983 _cpp_backup_tokens (pfile, 1);
985 /* If it's a #line directive, handle it. */
986 if (token1->type == CPP_NUMBER)
988 _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
989 return;
993 /* Backup as if nothing happened. */
994 _cpp_backup_tokens (pfile, 1);
997 /* Handle pending command line options: -D, -U, -A, -imacros and
998 -include. This should be called after debugging has been properly
999 set up in the front ends. */
1000 void
1001 cpp_finish_options (pfile)
1002 cpp_reader *pfile;
1004 /* Install builtins and process command line macros etc. in the order
1005 they appeared, but only if not already preprocessed. */
1006 if (! CPP_OPTION (pfile, preprocessed))
1008 struct pending_option *p;
1010 _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
1011 init_builtins (pfile);
1012 _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
1013 for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
1014 (*p->handler) (pfile, p->arg);
1016 /* Scan -imacros files after command line defines, but before
1017 files given with -include. */
1018 while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
1020 if (push_include (pfile, p))
1022 pfile->buffer->return_at_eof = true;
1023 cpp_scan_nooutput (pfile);
1025 CPP_OPTION (pfile, pending)->imacros_head = p->next;
1026 free (p);
1030 free_chain (CPP_OPTION (pfile, pending)->directive_head);
1031 _cpp_push_next_buffer (pfile);
1034 /* Called to push the next buffer on the stack given by -include. If
1035 there are none, free the pending structure and restore the line map
1036 for the main file. */
1037 bool
1038 _cpp_push_next_buffer (pfile)
1039 cpp_reader *pfile;
1041 bool pushed = false;
1043 /* This is't pretty; we'd rather not be relying on this as a boolean
1044 for reverting the line map. Further, we only free the chains in
1045 this conditional, so an early call to cpp_finish / cpp_destroy
1046 will leak that memory. */
1047 if (CPP_OPTION (pfile, pending)
1048 && CPP_OPTION (pfile, pending)->imacros_head == NULL)
1050 while (!pushed)
1052 struct pending_option *p = CPP_OPTION (pfile, pending)->include_head;
1054 if (p == NULL)
1055 break;
1056 if (! CPP_OPTION (pfile, preprocessed))
1057 pushed = push_include (pfile, p);
1058 CPP_OPTION (pfile, pending)->include_head = p->next;
1059 free (p);
1062 if (!pushed)
1064 free (CPP_OPTION (pfile, pending));
1065 CPP_OPTION (pfile, pending) = NULL;
1067 /* Restore the line map for the main file. */
1068 if (! CPP_OPTION (pfile, preprocessed))
1069 _cpp_do_file_change (pfile, LC_RENAME,
1070 pfile->line_maps.maps[0].to_file, 1, 0);
1074 return pushed;
1077 /* Use mkdeps.c to output dependency information. */
1078 static void
1079 output_deps (pfile)
1080 cpp_reader *pfile;
1082 /* Stream on which to print the dependency information. */
1083 FILE *deps_stream = 0;
1084 const char *const deps_mode =
1085 CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
1087 if (CPP_OPTION (pfile, deps_file)[0] == '\0')
1088 deps_stream = stdout;
1089 else
1091 deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
1092 if (deps_stream == 0)
1094 cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
1095 return;
1099 deps_write (pfile->deps, deps_stream, 72);
1101 if (CPP_OPTION (pfile, deps_phony_targets))
1102 deps_phony_targets (pfile->deps, deps_stream);
1104 /* Don't close stdout. */
1105 if (deps_stream != stdout)
1107 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1108 cpp_fatal (pfile, "I/O error on output");
1112 /* This is called at the end of preprocessing. It pops the
1113 last buffer and writes dependency output. It should also
1114 clear macro definitions, such that you could call cpp_start_read
1115 with a new filename to restart processing. */
1116 void
1117 cpp_finish (pfile)
1118 cpp_reader *pfile;
1120 /* cpplex.c leaves the final buffer on the stack. This it so that
1121 it returns an unending stream of CPP_EOFs to the client. If we
1122 popped the buffer, we'd dereference a NULL buffer pointer and
1123 segfault. It's nice to allow the client to do worry-free excess
1124 cpp_get_token calls. */
1125 while (pfile->buffer)
1126 _cpp_pop_buffer (pfile);
1128 /* Don't write the deps file if preprocessing has failed. */
1129 if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
1130 output_deps (pfile);
1132 /* Report on headers that could use multiple include guards. */
1133 if (CPP_OPTION (pfile, print_include_names))
1134 _cpp_report_missing_guards (pfile);
1137 /* Add a directive to be handled later in the initialization phase. */
1138 static void
1139 new_pending_directive (pend, text, handler)
1140 struct cpp_pending *pend;
1141 const char *text;
1142 cl_directive_handler handler;
1144 struct pending_option *o = (struct pending_option *)
1145 xmalloc (sizeof (struct pending_option));
1147 o->arg = text;
1148 o->next = NULL;
1149 o->handler = handler;
1150 APPEND (pend, directive, o);
1153 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1154 I.e. a const string initializer with parens around it. That is
1155 what N_("string") resolves to, so we make no_* be macros instead. */
1156 #define no_arg N_("argument missing after %s")
1157 #define no_ass N_("assertion missing after %s")
1158 #define no_dir N_("directory name missing after %s")
1159 #define no_fil N_("file name missing after %s")
1160 #define no_mac N_("macro name missing after %s")
1161 #define no_pth N_("path name missing after %s")
1162 #define no_num N_("number missing after %s")
1163 #define no_tgt N_("target missing after %s")
1165 /* This is the list of all command line options, with the leading
1166 "-" removed. It must be sorted in ASCII collating order. */
1167 #define COMMAND_LINE_OPTIONS \
1168 DEF_OPT("$", 0, OPT_dollar) \
1169 DEF_OPT("+", 0, OPT_plus) \
1170 DEF_OPT("-help", 0, OPT__help) \
1171 DEF_OPT("-target-help", 0, OPT_target__help) \
1172 DEF_OPT("-version", 0, OPT__version) \
1173 DEF_OPT("A", no_ass, OPT_A) \
1174 DEF_OPT("C", 0, OPT_C) \
1175 DEF_OPT("D", no_mac, OPT_D) \
1176 DEF_OPT("H", 0, OPT_H) \
1177 DEF_OPT("I", no_dir, OPT_I) \
1178 DEF_OPT("M", 0, OPT_M) \
1179 DEF_OPT("MD", no_fil, OPT_MD) \
1180 DEF_OPT("MF", no_fil, OPT_MF) \
1181 DEF_OPT("MG", 0, OPT_MG) \
1182 DEF_OPT("MM", 0, OPT_MM) \
1183 DEF_OPT("MMD", no_fil, OPT_MMD) \
1184 DEF_OPT("MP", 0, OPT_MP) \
1185 DEF_OPT("MQ", no_tgt, OPT_MQ) \
1186 DEF_OPT("MT", no_tgt, OPT_MT) \
1187 DEF_OPT("P", 0, OPT_P) \
1188 DEF_OPT("U", no_mac, OPT_U) \
1189 DEF_OPT("W", no_arg, OPT_W) /* arg optional */ \
1190 DEF_OPT("d", no_arg, OPT_d) \
1191 DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore) \
1192 DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore) \
1193 DEF_OPT("fno-operator-names", 0, OPT_fno_operator_names) \
1194 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed) \
1195 DEF_OPT("fno-show-column", 0, OPT_fno_show_column) \
1196 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed) \
1197 DEF_OPT("fshow-column", 0, OPT_fshow_column) \
1198 DEF_OPT("fsigned-char", 0, OPT_fsigned_char) \
1199 DEF_OPT("ftabstop=", no_num, OPT_ftabstop) \
1200 DEF_OPT("funsigned-char", 0, OPT_funsigned_char) \
1201 DEF_OPT("h", 0, OPT_h) \
1202 DEF_OPT("idirafter", no_dir, OPT_idirafter) \
1203 DEF_OPT("imacros", no_fil, OPT_imacros) \
1204 DEF_OPT("include", no_fil, OPT_include) \
1205 DEF_OPT("iprefix", no_pth, OPT_iprefix) \
1206 DEF_OPT("isystem", no_dir, OPT_isystem) \
1207 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix) \
1208 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore) \
1209 DEF_OPT("lang-asm", 0, OPT_lang_asm) \
1210 DEF_OPT("lang-c", 0, OPT_lang_c) \
1211 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus) \
1212 DEF_OPT("lang-c89", 0, OPT_lang_c89) \
1213 DEF_OPT("lang-objc", 0, OPT_lang_objc) \
1214 DEF_OPT("lang-objc++", 0, OPT_lang_objcplusplus) \
1215 DEF_OPT("nostdinc", 0, OPT_nostdinc) \
1216 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus) \
1217 DEF_OPT("o", no_fil, OPT_o) \
1218 DEF_OPT("pedantic", 0, OPT_pedantic) \
1219 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors) \
1220 DEF_OPT("remap", 0, OPT_remap) \
1221 DEF_OPT("std=c++98", 0, OPT_std_cplusplus98) \
1222 DEF_OPT("std=c89", 0, OPT_std_c89) \
1223 DEF_OPT("std=c99", 0, OPT_std_c99) \
1224 DEF_OPT("std=c9x", 0, OPT_std_c9x) \
1225 DEF_OPT("std=gnu89", 0, OPT_std_gnu89) \
1226 DEF_OPT("std=gnu99", 0, OPT_std_gnu99) \
1227 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x) \
1228 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990) \
1229 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409) \
1230 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999) \
1231 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x) \
1232 DEF_OPT("trigraphs", 0, OPT_trigraphs) \
1233 DEF_OPT("v", 0, OPT_v) \
1234 DEF_OPT("version", 0, OPT_version) \
1235 DEF_OPT("w", 0, OPT_w)
1237 #define DEF_OPT(text, msg, code) code,
1238 enum opt_code
1240 COMMAND_LINE_OPTIONS
1241 N_OPTS
1243 #undef DEF_OPT
1245 struct cl_option
1247 const char *opt_text;
1248 const char *msg;
1249 size_t opt_len;
1250 enum opt_code opt_code;
1253 #define DEF_OPT(text, msg, code) { text, msg, sizeof(text) - 1, code },
1254 #ifdef HOST_EBCDIC
1255 static struct cl_option cl_options[] =
1256 #else
1257 static const struct cl_option cl_options[] =
1258 #endif
1260 COMMAND_LINE_OPTIONS
1262 #undef DEF_OPT
1263 #undef COMMAND_LINE_OPTIONS
1265 /* Perform a binary search to find which, if any, option the given
1266 command-line matches. Returns its index in the option array,
1267 negative on failure. Complications arise since some options can be
1268 suffixed with an argument, and multiple complete matches can occur,
1269 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
1270 accept options beginning with -W that we do not recognise, but not
1271 to swallow any subsequent command line argument; this is handled as
1272 special cases in cpp_handle_option. */
1273 static int
1274 parse_option (input)
1275 const char *input;
1277 unsigned int md, mn, mx;
1278 size_t opt_len;
1279 int comp;
1281 mn = 0;
1282 mx = N_OPTS;
1284 while (mx > mn)
1286 md = (mn + mx) / 2;
1288 opt_len = cl_options[md].opt_len;
1289 comp = memcmp (input, cl_options[md].opt_text, opt_len);
1291 if (comp > 0)
1292 mn = md + 1;
1293 else if (comp < 0)
1294 mx = md;
1295 else
1297 if (input[opt_len] == '\0')
1298 return md;
1299 /* We were passed more text. If the option takes an argument,
1300 we may match a later option or we may have been passed the
1301 argument. The longest possible option match succeeds.
1302 If the option takes no arguments we have not matched and
1303 continue the search (e.g. input="stdc++" match was "stdc"). */
1304 mn = md + 1;
1305 if (cl_options[md].msg)
1307 /* Scan forwards. If we get an exact match, return it.
1308 Otherwise, return the longest option-accepting match.
1309 This loops no more than twice with current options. */
1310 mx = md;
1311 for (; mn < (unsigned int) N_OPTS; mn++)
1313 opt_len = cl_options[mn].opt_len;
1314 if (memcmp (input, cl_options[mn].opt_text, opt_len))
1315 break;
1316 if (input[opt_len] == '\0')
1317 return mn;
1318 if (cl_options[mn].msg)
1319 mx = mn;
1321 return mx;
1326 return -1;
1329 /* Handle one command-line option in (argc, argv).
1330 Can be called multiple times, to handle multiple sets of options.
1331 If ignore is non-zero, this will ignore unrecognized -W* options.
1332 Returns number of strings consumed. */
1334 cpp_handle_option (pfile, argc, argv, ignore)
1335 cpp_reader *pfile;
1336 int argc;
1337 char **argv;
1338 int ignore;
1340 int i = 0;
1341 struct cpp_pending *pend = CPP_OPTION (pfile, pending);
1343 /* Interpret "-" or a non-option as a file name. */
1344 if (argv[i][0] != '-' || argv[i][1] == '\0')
1346 if (CPP_OPTION (pfile, in_fname) == NULL)
1347 CPP_OPTION (pfile, in_fname) = argv[i];
1348 else if (CPP_OPTION (pfile, out_fname) == NULL)
1349 CPP_OPTION (pfile, out_fname) = argv[i];
1350 else
1351 cpp_fatal (pfile, "too many filenames. Type %s --help for usage info",
1352 progname);
1354 else
1356 enum opt_code opt_code;
1357 int opt_index;
1358 const char *arg = 0;
1360 /* Skip over '-'. */
1361 opt_index = parse_option (&argv[i][1]);
1362 if (opt_index < 0)
1363 return i;
1365 opt_code = cl_options[opt_index].opt_code;
1366 if (cl_options[opt_index].msg)
1368 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1370 /* Yuk. Special case for -W as it must not swallow
1371 up any following argument. If this becomes common, add
1372 another field to the cl_options table. */
1373 if (arg[0] == '\0' && opt_code != OPT_W)
1375 arg = argv[++i];
1376 if (!arg)
1378 cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
1379 return argc;
1384 switch (opt_code)
1386 case N_OPTS: /* Shut GCC up. */
1387 break;
1388 case OPT_fleading_underscore:
1389 CPP_OPTION (pfile, user_label_prefix) = "_";
1390 break;
1391 case OPT_fno_leading_underscore:
1392 CPP_OPTION (pfile, user_label_prefix) = "";
1393 break;
1394 case OPT_fno_operator_names:
1395 CPP_OPTION (pfile, operator_names) = 0;
1396 break;
1397 case OPT_fpreprocessed:
1398 CPP_OPTION (pfile, preprocessed) = 1;
1399 break;
1400 case OPT_fno_preprocessed:
1401 CPP_OPTION (pfile, preprocessed) = 0;
1402 break;
1403 case OPT_fshow_column:
1404 CPP_OPTION (pfile, show_column) = 1;
1405 break;
1406 case OPT_fno_show_column:
1407 CPP_OPTION (pfile, show_column) = 0;
1408 break;
1409 case OPT_fsigned_char:
1410 CPP_OPTION (pfile, signed_char) = 1;
1411 break;
1412 case OPT_funsigned_char:
1413 CPP_OPTION (pfile, signed_char) = 0;
1414 break;
1415 case OPT_ftabstop:
1416 /* Silently ignore empty string, non-longs and silly values. */
1417 if (arg[0] != '\0')
1419 char *endptr;
1420 long tabstop = strtol (arg, &endptr, 10);
1421 if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
1422 CPP_OPTION (pfile, tabstop) = tabstop;
1424 break;
1425 case OPT_w:
1426 CPP_OPTION (pfile, inhibit_warnings) = 1;
1427 break;
1428 case OPT_h:
1429 case OPT__help:
1430 print_help ();
1431 CPP_OPTION (pfile, help_only) = 1;
1432 break;
1433 case OPT_target__help:
1434 /* Print if any target specific options. cpplib has none, but
1435 make sure help_only gets set. */
1436 CPP_OPTION (pfile, help_only) = 1;
1437 break;
1439 /* --version inhibits compilation, -version doesn't. -v means
1440 verbose and -version. Historical reasons, don't ask. */
1441 case OPT__version:
1442 CPP_OPTION (pfile, help_only) = 1;
1443 pfile->print_version = 1;
1444 break;
1445 case OPT_v:
1446 CPP_OPTION (pfile, verbose) = 1;
1447 pfile->print_version = 1;
1448 break;
1449 case OPT_version:
1450 pfile->print_version = 1;
1451 break;
1453 case OPT_C:
1454 CPP_OPTION (pfile, discard_comments) = 0;
1455 break;
1456 case OPT_P:
1457 CPP_OPTION (pfile, no_line_commands) = 1;
1458 break;
1459 case OPT_dollar: /* Don't include $ in identifiers. */
1460 CPP_OPTION (pfile, dollars_in_ident) = 0;
1461 break;
1462 case OPT_H:
1463 CPP_OPTION (pfile, print_include_names) = 1;
1464 break;
1465 case OPT_D:
1466 new_pending_directive (pend, arg, cpp_define);
1467 break;
1468 case OPT_pedantic_errors:
1469 CPP_OPTION (pfile, pedantic_errors) = 1;
1470 /* fall through */
1471 case OPT_pedantic:
1472 CPP_OPTION (pfile, pedantic) = 1;
1473 break;
1474 case OPT_trigraphs:
1475 CPP_OPTION (pfile, trigraphs) = 1;
1476 break;
1477 case OPT_plus:
1478 CPP_OPTION (pfile, cplusplus) = 1;
1479 CPP_OPTION (pfile, cplusplus_comments) = 1;
1480 break;
1481 case OPT_remap:
1482 CPP_OPTION (pfile, remap) = 1;
1483 break;
1484 case OPT_iprefix:
1485 CPP_OPTION (pfile, include_prefix) = arg;
1486 CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
1487 break;
1488 case OPT_lang_c:
1489 set_lang (pfile, CLK_GNUC89);
1490 break;
1491 case OPT_lang_cplusplus:
1492 set_lang (pfile, CLK_GNUCXX);
1493 break;
1494 case OPT_lang_objc:
1495 set_lang (pfile, CLK_OBJC);
1496 break;
1497 case OPT_lang_objcplusplus:
1498 set_lang (pfile, CLK_OBJCXX);
1499 break;
1500 case OPT_lang_asm:
1501 set_lang (pfile, CLK_ASM);
1502 break;
1503 case OPT_std_cplusplus98:
1504 set_lang (pfile, CLK_CXX98);
1505 break;
1506 case OPT_std_gnu89:
1507 set_lang (pfile, CLK_GNUC89);
1508 break;
1509 case OPT_std_gnu9x:
1510 case OPT_std_gnu99:
1511 set_lang (pfile, CLK_GNUC99);
1512 break;
1513 case OPT_std_iso9899_199409:
1514 set_lang (pfile, CLK_STDC94);
1515 break;
1516 case OPT_std_iso9899_1990:
1517 case OPT_std_c89:
1518 case OPT_lang_c89:
1519 set_lang (pfile, CLK_STDC89);
1520 break;
1521 case OPT_std_iso9899_199x:
1522 case OPT_std_iso9899_1999:
1523 case OPT_std_c9x:
1524 case OPT_std_c99:
1525 set_lang (pfile, CLK_STDC99);
1526 break;
1527 case OPT_nostdinc:
1528 /* -nostdinc causes no default include directories.
1529 You must specify all include-file directories with -I. */
1530 CPP_OPTION (pfile, no_standard_includes) = 1;
1531 break;
1532 case OPT_nostdincplusplus:
1533 /* -nostdinc++ causes no default C++-specific include directories. */
1534 CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
1535 break;
1536 case OPT_o:
1537 if (CPP_OPTION (pfile, out_fname) == NULL)
1538 CPP_OPTION (pfile, out_fname) = arg;
1539 else
1541 cpp_fatal (pfile, "output filename specified twice");
1542 return argc;
1544 break;
1545 case OPT_d:
1546 /* Args to -d specify what parts of macros to dump.
1547 Silently ignore unrecognised options; they may
1548 be aimed at the compiler proper. */
1550 char c;
1552 while ((c = *arg++) != '\0')
1553 switch (c)
1555 case 'M':
1556 CPP_OPTION (pfile, dump_macros) = dump_only;
1557 CPP_OPTION (pfile, no_output) = 1;
1558 break;
1559 case 'N':
1560 CPP_OPTION (pfile, dump_macros) = dump_names;
1561 break;
1562 case 'D':
1563 CPP_OPTION (pfile, dump_macros) = dump_definitions;
1564 break;
1565 case 'I':
1566 CPP_OPTION (pfile, dump_includes) = 1;
1567 break;
1570 break;
1572 case OPT_MG:
1573 CPP_OPTION (pfile, print_deps_missing_files) = 1;
1574 break;
1575 case OPT_M:
1576 CPP_OPTION (pfile, print_deps) = 2;
1577 break;
1578 case OPT_MM:
1579 CPP_OPTION (pfile, print_deps) = 1;
1580 break;
1581 case OPT_MF:
1582 CPP_OPTION (pfile, deps_file) = arg;
1583 break;
1584 case OPT_MP:
1585 CPP_OPTION (pfile, deps_phony_targets) = 1;
1586 break;
1587 case OPT_MQ:
1588 case OPT_MT:
1589 /* Add a target. -MQ quotes for Make. */
1590 deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
1591 break;
1593 /* -MD and -MMD for cpp0 are deprecated and undocumented
1594 (use -M or -MM with -MF instead), and probably should be
1595 removed with the next major GCC version. For the moment
1596 we allow these for the benefit of Automake 1.4, which
1597 uses these when dependency tracking is enabled. Automake
1598 1.5 will fix this. */
1599 case OPT_MD:
1600 CPP_OPTION (pfile, print_deps) = 2;
1601 CPP_OPTION (pfile, deps_file) = arg;
1602 break;
1603 case OPT_MMD:
1604 CPP_OPTION (pfile, print_deps) = 1;
1605 CPP_OPTION (pfile, deps_file) = arg;
1606 break;
1608 case OPT_A:
1609 if (arg[0] == '-')
1611 /* -A with an argument beginning with '-' acts as
1612 #unassert on whatever immediately follows the '-'.
1613 If "-" is the whole argument, we eliminate all
1614 predefined macros and assertions, including those
1615 that were specified earlier on the command line.
1616 That way we can get rid of any that were passed
1617 automatically in from GCC. */
1619 if (arg[1] == '\0')
1621 free_chain (pend->directive_head);
1622 pend->directive_head = NULL;
1623 pend->directive_tail = NULL;
1625 else
1626 new_pending_directive (pend, arg + 1, cpp_unassert);
1628 else
1629 new_pending_directive (pend, arg, cpp_assert);
1630 break;
1631 case OPT_U:
1632 new_pending_directive (pend, arg, cpp_undef);
1633 break;
1634 case OPT_I: /* Add directory to path for includes. */
1635 if (!strcmp (arg, "-"))
1637 /* -I- means:
1638 Use the preceding -I directories for #include "..."
1639 but not #include <...>.
1640 Don't search the directory of the present file
1641 for #include "...". (Note that -I. -I- is not the same as
1642 the default setup; -I. uses the compiler's working dir.) */
1643 if (! CPP_OPTION (pfile, ignore_srcdir))
1645 pend->quote_head = pend->brack_head;
1646 pend->quote_tail = pend->brack_tail;
1647 pend->brack_head = 0;
1648 pend->brack_tail = 0;
1649 CPP_OPTION (pfile, ignore_srcdir) = 1;
1651 else
1653 cpp_fatal (pfile, "-I- specified twice");
1654 return argc;
1657 else
1658 append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
1659 break;
1660 case OPT_isystem:
1661 /* Add directory to beginning of system include path, as a system
1662 include directory. */
1663 append_include_chain (pfile, xstrdup (arg), SYSTEM, 0);
1664 break;
1665 case OPT_include:
1666 case OPT_imacros:
1668 struct pending_option *o = (struct pending_option *)
1669 xmalloc (sizeof (struct pending_option));
1670 o->arg = arg;
1671 o->next = NULL;
1673 if (opt_code == OPT_include)
1674 APPEND (pend, include, o);
1675 else
1676 APPEND (pend, imacros, o);
1678 break;
1679 case OPT_iwithprefix:
1680 /* Add directory to end of path for includes,
1681 with the default prefix at the front of its name. */
1682 /* fall through */
1683 case OPT_iwithprefixbefore:
1684 /* Add directory to main path for includes,
1685 with the default prefix at the front of its name. */
1687 char *fname;
1688 int len;
1690 len = strlen (arg);
1692 if (CPP_OPTION (pfile, include_prefix) != 0)
1694 size_t ipl = CPP_OPTION (pfile, include_prefix_len);
1695 fname = xmalloc (ipl + len + 1);
1696 memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
1697 memcpy (fname + ipl, arg, len + 1);
1699 else if (cpp_GCC_INCLUDE_DIR_len)
1701 fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
1702 memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
1703 memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
1705 else
1706 fname = xstrdup (arg);
1708 append_include_chain (pfile, fname,
1709 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1711 break;
1712 case OPT_idirafter:
1713 /* Add directory to end of path for includes. */
1714 append_include_chain (pfile, xstrdup (arg), AFTER, 0);
1715 break;
1716 case OPT_W:
1717 /* Silently ignore unrecognised options. */
1718 if (!strcmp (argv[i], "-Wall"))
1720 CPP_OPTION (pfile, warn_trigraphs) = 1;
1721 CPP_OPTION (pfile, warn_comments) = 1;
1723 else if (!strcmp (argv[i], "-Wtraditional"))
1724 CPP_OPTION (pfile, warn_traditional) = 1;
1725 else if (!strcmp (argv[i], "-Wtrigraphs"))
1726 CPP_OPTION (pfile, warn_trigraphs) = 1;
1727 else if (!strcmp (argv[i], "-Wcomment"))
1728 CPP_OPTION (pfile, warn_comments) = 1;
1729 else if (!strcmp (argv[i], "-Wcomments"))
1730 CPP_OPTION (pfile, warn_comments) = 1;
1731 else if (!strcmp (argv[i], "-Wundef"))
1732 CPP_OPTION (pfile, warn_undef) = 1;
1733 else if (!strcmp (argv[i], "-Wimport"))
1734 CPP_OPTION (pfile, warn_import) = 1;
1735 else if (!strcmp (argv[i], "-Werror"))
1736 CPP_OPTION (pfile, warnings_are_errors) = 1;
1737 else if (!strcmp (argv[i], "-Wsystem-headers"))
1738 CPP_OPTION (pfile, warn_system_headers) = 1;
1739 else if (!strcmp (argv[i], "-Wno-traditional"))
1740 CPP_OPTION (pfile, warn_traditional) = 0;
1741 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1742 CPP_OPTION (pfile, warn_trigraphs) = 0;
1743 else if (!strcmp (argv[i], "-Wno-comment"))
1744 CPP_OPTION (pfile, warn_comments) = 0;
1745 else if (!strcmp (argv[i], "-Wno-comments"))
1746 CPP_OPTION (pfile, warn_comments) = 0;
1747 else if (!strcmp (argv[i], "-Wno-undef"))
1748 CPP_OPTION (pfile, warn_undef) = 0;
1749 else if (!strcmp (argv[i], "-Wno-import"))
1750 CPP_OPTION (pfile, warn_import) = 0;
1751 else if (!strcmp (argv[i], "-Wno-error"))
1752 CPP_OPTION (pfile, warnings_are_errors) = 0;
1753 else if (!strcmp (argv[i], "-Wno-system-headers"))
1754 CPP_OPTION (pfile, warn_system_headers) = 0;
1755 else if (! ignore)
1756 return i;
1757 break;
1760 return i + 1;
1763 /* Handle command-line options in (argc, argv).
1764 Can be called multiple times, to handle multiple sets of options.
1765 Returns if an unrecognized option is seen.
1766 Returns number of strings consumed. */
1768 cpp_handle_options (pfile, argc, argv)
1769 cpp_reader *pfile;
1770 int argc;
1771 char **argv;
1773 int i;
1774 int strings_processed;
1776 for (i = 0; i < argc; i += strings_processed)
1778 strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
1779 if (strings_processed == 0)
1780 break;
1783 return i;
1786 /* Extra processing when all options are parsed, after all calls to
1787 cpp_handle_option[s]. Consistency checks etc. */
1788 void
1789 cpp_post_options (pfile)
1790 cpp_reader *pfile;
1792 if (pfile->print_version)
1794 fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
1795 #ifdef TARGET_VERSION
1796 TARGET_VERSION;
1797 #endif
1798 fputc ('\n', stderr);
1801 /* Canonicalize in_fname and out_fname. We guarantee they are not
1802 NULL, and that the empty string represents stdin / stdout. */
1803 if (CPP_OPTION (pfile, in_fname) == NULL
1804 || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
1805 CPP_OPTION (pfile, in_fname) = "";
1807 if (CPP_OPTION (pfile, out_fname) == NULL
1808 || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
1809 CPP_OPTION (pfile, out_fname) = "";
1811 /* -Wtraditional is not useful in C++ mode. */
1812 if (CPP_OPTION (pfile, cplusplus))
1813 CPP_OPTION (pfile, warn_traditional) = 0;
1815 /* Set this if it hasn't been set already. */
1816 if (CPP_OPTION (pfile, user_label_prefix) == NULL)
1817 CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
1819 /* Permanently disable macro expansion if we are rescanning
1820 preprocessed text. */
1821 if (CPP_OPTION (pfile, preprocessed))
1822 pfile->state.prevent_expansion = 1;
1824 /* We need to do this after option processing and before
1825 cpp_start_read, as cppmain.c relies on the options->no_output to
1826 set its callbacks correctly before calling cpp_start_read. */
1827 init_dependency_output (pfile);
1829 /* After checking the environment variables, check if -M or -MM has
1830 not been specified, but other -M options have. */
1831 if (CPP_OPTION (pfile, print_deps) == 0 &&
1832 (CPP_OPTION (pfile, print_deps_missing_files)
1833 || CPP_OPTION (pfile, deps_file)
1834 || CPP_OPTION (pfile, deps_phony_targets)))
1835 cpp_fatal (pfile, "you must additionally specify either -M or -MM");
1838 /* Set up dependency-file output. On exit, if print_deps is non-zero
1839 then deps_file is not NULL; stdout is the empty string. */
1840 static void
1841 init_dependency_output (pfile)
1842 cpp_reader *pfile;
1844 char *spec, *s, *output_file;
1846 /* Either of two environment variables can specify output of deps.
1847 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
1848 where OUTPUT_FILE is the file to write deps info to
1849 and DEPS_TARGET is the target to mention in the deps. */
1851 if (CPP_OPTION (pfile, print_deps) == 0)
1853 spec = getenv ("DEPENDENCIES_OUTPUT");
1854 if (spec)
1855 CPP_OPTION (pfile, print_deps) = 1;
1856 else
1858 spec = getenv ("SUNPRO_DEPENDENCIES");
1859 if (spec)
1860 CPP_OPTION (pfile, print_deps) = 2;
1861 else
1862 return;
1865 /* Find the space before the DEPS_TARGET, if there is one. */
1866 s = strchr (spec, ' ');
1867 if (s)
1869 /* Let the caller perform MAKE quoting. */
1870 deps_add_target (pfile->deps, s + 1, 0);
1871 output_file = (char *) xmalloc (s - spec + 1);
1872 memcpy (output_file, spec, s - spec);
1873 output_file[s - spec] = 0;
1875 else
1876 output_file = spec;
1878 /* Command line -MF overrides environment variables and default. */
1879 if (CPP_OPTION (pfile, deps_file) == 0)
1880 CPP_OPTION (pfile, deps_file) = output_file;
1882 CPP_OPTION (pfile, print_deps_append) = 1;
1884 else if (CPP_OPTION (pfile, deps_file) == 0)
1885 /* If -M or -MM was seen, default output to wherever was specified
1886 with -o. out_fname is non-NULL here. */
1887 CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
1889 /* When doing dependencies, we should suppress all output, including
1890 -dM, -dI etc. */
1891 CPP_OPTION (pfile, no_output) = 1;
1892 CPP_OPTION (pfile, dump_macros) = 0;
1893 CPP_OPTION (pfile, dump_includes) = 0;
1896 /* Handle --help output. */
1897 static void
1898 print_help ()
1900 fprintf (stderr, _("Usage: %s [switches] input output\n"), progname);
1901 /* To keep the lines from getting too long for some compilers, limit
1902 to about 500 characters (6 lines) per chunk. */
1903 fputs (_("\
1904 Switches:\n\
1905 -include <file> Include the contents of <file> before other files\n\
1906 -imacros <file> Accept definition of macros in <file>\n\
1907 -iprefix <path> Specify <path> as a prefix for next two options\n\
1908 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1909 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1910 -isystem <dir> Add <dir> to the start of the system include path\n\
1911 "), stdout);
1912 fputs (_("\
1913 -idirafter <dir> Add <dir> to the end of the system include path\n\
1914 -I <dir> Add <dir> to the end of the main include path\n\
1915 -I- Fine-grained include path control; see info docs\n\
1916 -nostdinc Do not search system include directories\n\
1917 (dirs specified with -isystem will still be used)\n\
1918 -nostdinc++ Do not search system include directories for C++\n\
1919 -o <file> Put output into <file>\n\
1920 "), stdout);
1921 fputs (_("\
1922 -pedantic Issue all warnings demanded by strict ISO C\n\
1923 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1924 -trigraphs Support ISO C trigraphs\n\
1925 -lang-c Assume that the input sources are in C\n\
1926 -lang-c89 Assume that the input sources are in C89\n\
1927 "), stdout);
1928 fputs (_("\
1929 -lang-c++ Assume that the input sources are in C++\n\
1930 -lang-objc Assume that the input sources are in ObjectiveC\n\
1931 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1932 -lang-asm Assume that the input sources are in assembler\n\
1933 "), stdout);
1934 fputs (_("\
1935 -std=<std name> Specify the conformance standard; one of:\n\
1936 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1937 iso9899:199409, iso9899:1999\n\
1938 -+ Allow parsing of C++ style features\n\
1939 -w Inhibit warning messages\n\
1940 -Wtrigraphs Warn if trigraphs are encountered\n\
1941 -Wno-trigraphs Do not warn about trigraphs\n\
1942 -Wcomment{s} Warn if one comment starts inside another\n\
1943 "), stdout);
1944 fputs (_("\
1945 -Wno-comment{s} Do not warn about comments\n\
1946 -Wtraditional Warn about features not present in traditional C\n\
1947 -Wno-traditional Do not warn about traditional C\n\
1948 -Wundef Warn if an undefined macro is used by #if\n\
1949 -Wno-undef Do not warn about testing undefined macros\n\
1950 -Wimport Warn about the use of the #import directive\n\
1951 "), stdout);
1952 fputs (_("\
1953 -Wno-import Do not warn about the use of #import\n\
1954 -Werror Treat all warnings as errors\n\
1955 -Wno-error Do not treat warnings as errors\n\
1956 -Wsystem-headers Do not suppress warnings from system headers\n\
1957 -Wno-system-headers Suppress warnings from system headers\n\
1958 -Wall Enable all preprocessor warnings\n\
1959 "), stdout);
1960 fputs (_("\
1961 -M Generate make dependencies\n\
1962 -MM As -M, but ignore system header files\n\
1963 -MF <file> Write dependency output to the given file\n\
1964 -MG Treat missing header file as generated files\n\
1965 "), stdout);
1966 fputs (_("\
1967 -MP Generate phony targets for all headers\n\
1968 -MQ <target> Add a MAKE-quoted target\n\
1969 -MT <target> Add an unquoted target\n\
1970 "), stdout);
1971 fputs (_("\
1972 -D<macro> Define a <macro> with string '1' as its value\n\
1973 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1974 -A<question> (<answer>) Assert the <answer> to <question>\n\
1975 -A-<question> (<answer>) Disable the <answer> to <question>\n\
1976 -U<macro> Undefine <macro> \n\
1977 -v Display the version number\n\
1978 "), stdout);
1979 fputs (_("\
1980 -H Print the name of header files as they are used\n\
1981 -C Do not discard comments\n\
1982 -dM Display a list of macro definitions active at end\n\
1983 -dD Preserve macro definitions in output\n\
1984 -dN As -dD except that only the names are preserved\n\
1985 -dI Include #include directives in the output\n\
1986 "), stdout);
1987 fputs (_("\
1988 -fpreprocessed Treat the input file as already preprocessed\n\
1989 -ftabstop=<number> Distance between tab stops for column reporting\n\
1990 -P Do not generate #line directives\n\
1991 -$ Do not allow '$' in identifiers\n\
1992 -remap Remap file names when including files.\n\
1993 --version Display version information\n\
1994 -h or --help Display this information\n\
1995 "), stdout);