2 Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 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
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. */
34 /* Predefined symbols, built-in macros, and the default include path. */
36 #ifndef GET_ENV_PATH_LIST
37 #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
40 /* Windows does not natively support inodes, and neither does MSDOS.
41 Cygwin's emulation can generate non-unique inodes, so don't use it.
42 VMS has non-numeric inodes. */
44 #define INO_T_EQ(a, b) (!memcmp (&(a), &(b), sizeof (a)))
45 #elif (defined _WIN32 && ! defined (_UWIN)) || defined __MSDOS__
46 #define INO_T_EQ(a, b) 0
48 #define INO_T_EQ(a, b) ((a) == (b))
51 #ifndef STANDARD_INCLUDE_DIR
52 #define STANDARD_INCLUDE_DIR "/usr/include"
55 /* We let tm.h override the types used here, to handle trivial differences
56 such as the choice of unsigned int or long unsigned int for size_t.
57 When machines start needing nontrivial differences in the size type,
58 it would be best to do something here to figure out automatically
59 from other information what type to use. */
61 /* The string value for __SIZE_TYPE__. */
64 #define SIZE_TYPE "long unsigned int"
67 /* The string value for __PTRDIFF_TYPE__. */
70 #define PTRDIFF_TYPE "long int"
73 /* The string value for __WCHAR_TYPE__. */
76 #define WCHAR_TYPE "int"
79 /* The string value for __USER_LABEL_PREFIX__ */
81 #ifndef USER_LABEL_PREFIX
82 #define USER_LABEL_PREFIX ""
85 /* The string value for __REGISTER_PREFIX__ */
87 #ifndef REGISTER_PREFIX
88 #define REGISTER_PREFIX ""
91 /* This is the default list of directories to search for include files.
92 It may be overridden by the various -I and -ixxx options.
94 #include "file" looks in the same directory as the current file,
96 #include <file> just looks in this list.
98 All these directories are treated as `system' include directories
99 (they are not subject to pedantic warnings in some cases). */
101 struct default_include
103 const char *fname; /* The name of the directory. */
104 const char *component; /* The component containing the directory
105 (see update_path in prefix.c) */
106 int cplusplus; /* Only look here if we're compiling C++. */
107 int cxx_aware; /* Includes in this directory don't need to
108 be wrapped in extern "C" when compiling
112 #ifndef STANDARD_INCLUDE_COMPONENT
113 #define STANDARD_INCLUDE_COMPONENT 0
117 #undef LOCAL_INCLUDE_DIR
118 #undef SYSTEM_INCLUDE_DIR
119 #undef STANDARD_INCLUDE_DIR
121 #undef CROSS_INCLUDE_DIR
124 static const struct default_include include_defaults_array[]
125 #ifdef INCLUDE_DEFAULTS
129 #ifdef GPLUSPLUS_INCLUDE_DIR
130 /* Pick up GNU C++ specific include files. */
131 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
133 #ifdef LOCAL_INCLUDE_DIR
134 /* /usr/local/include comes before the fixincluded header files. */
135 { LOCAL_INCLUDE_DIR, 0, 0, 1 },
137 #ifdef GCC_INCLUDE_DIR
138 /* This is the dir for fixincludes and for gcc's private headers. */
139 { GCC_INCLUDE_DIR, "GCC", 0, 0 },
141 #ifdef CROSS_INCLUDE_DIR
142 /* One place the target system's headers might be. */
143 { CROSS_INCLUDE_DIR, "GCC", 0, 0 },
145 #ifdef TOOL_INCLUDE_DIR
146 /* Another place the target system's headers might be. */
147 { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
149 #ifdef SYSTEM_INCLUDE_DIR
150 /* Some systems have an extra dir of include files. */
151 { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
153 #ifdef STANDARD_INCLUDE_DIR
154 /* /usr/include comes dead last. */
155 { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
159 #endif /* no INCLUDE_DEFAULTS */
161 /* Internal structures and prototypes. */
163 /* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
164 switch. There are four lists: one for -D and -U, one for -A, one
165 for -include, one for -imacros. `undef' is set for -U, clear for
166 -D, ignored for the others.
167 (Future: add an equivalent of -U for -A) */
169 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
170 struct pending_option
172 struct pending_option *next;
174 cl_directive_handler handler;
177 /* The `pending' structure accumulates all the options that are not
178 actually processed until we hit cpp_start_read. It consists of
179 several lists, one for each type of option. We keep both head and
180 tail pointers for quick insertion. */
183 struct pending_option *directive_head, *directive_tail;
185 struct file_name_list *quote_head, *quote_tail;
186 struct file_name_list *brack_head, *brack_tail;
187 struct file_name_list *systm_head, *systm_tail;
188 struct file_name_list *after_head, *after_tail;
190 struct pending_option *imacros_head, *imacros_tail;
191 struct pending_option *include_head, *include_tail;
195 #define APPEND(pend, list, elt) \
196 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
197 else (pend)->list##_tail->next = (elt); \
198 (pend)->list##_tail = (elt); \
201 #define APPEND(pend, list, elt) \
202 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
203 else (pend)->list/**/_tail->next = (elt); \
204 (pend)->list/**/_tail = (elt); \
208 static void print_help PARAMS ((void));
209 static void path_include PARAMS ((cpp_reader *,
210 struct cpp_pending *,
212 static void initialize_builtins PARAMS ((cpp_reader *));
213 static void append_include_chain PARAMS ((cpp_reader *,
214 struct cpp_pending *,
216 static void merge_include_chains PARAMS ((struct cpp_options *));
218 static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *));
219 static void initialize_dependency_output PARAMS ((cpp_reader *));
220 static void initialize_standard_includes PARAMS ((cpp_reader *));
221 static void new_pending_directive PARAMS ((struct cpp_options *,
223 cl_directive_handler));
225 static int opt_comp PARAMS ((const void *, const void *));
227 static int parse_option PARAMS ((const char *));
228 static int handle_option PARAMS ((cpp_reader *, int, char **));
230 /* Fourth argument to append_include_chain: chain to use */
231 enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
233 /* If we have designated initializers (GCC >2.7, or C99) this table
234 can be initialized, constant data. Otherwise, it has to be filled
237 #if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)
238 #define init_IStable() /* nothing */
239 #define ISTABLE const unsigned char _cpp_IStable[256] = {
241 #define s(p, v) [p] = v,
243 #define ISTABLE unsigned char _cpp_IStable[256] = { 0 }; \
244 static void init_IStable PARAMS ((void)) { \
245 unsigned char *x = _cpp_IStable;
247 #define s(p, v) x[p] = v;
250 #define A(x) s(x, ISidnum|ISidstart)
251 #define N(x) s(x, ISidnum|ISnumstart)
252 #define H(x) s(x, IShspace|ISspace)
253 #define S(x) s(x, ISspace)
258 A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
259 A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
260 A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
262 A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
263 A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
264 A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
266 N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
268 H(' ') H('\t') H('\v') H('\f')
281 /* Given a colon-separated list of file names PATH,
282 add all the names to the search path for include files. */
285 path_include (pfile, pend, list, path)
287 struct cpp_pending *pend;
297 /* Find the end of this name. */
299 while (*q != 0 && *q != PATH_SEPARATOR) q++;
302 /* An empty name in the path stands for the current directory. */
303 name = (char *) xmalloc (2);
309 /* Otherwise use the directory that is named. */
310 name = (char *) xmalloc (q - p + 1);
311 memcpy (name, p, q - p);
315 append_include_chain (pfile, pend, name, path, 0);
317 /* Advance past this name. */
325 /* Append DIR to include path PATH. DIR must be permanently allocated
328 append_include_chain (pfile, pend, dir, path, cxx_aware)
330 struct cpp_pending *pend;
335 struct file_name_list *new;
339 _cpp_simplify_pathname (dir);
342 /* Dirs that don't exist are silently ignored. */
344 cpp_notice_from_errno (pfile, dir);
345 else if (CPP_OPTIONS (pfile)->verbose)
346 fprintf (stderr, _("ignoring nonexistent directory `%s'\n"), dir);
350 if (!S_ISDIR (st.st_mode))
352 cpp_notice (pfile, "%s: Not a directory", dir);
357 if (len > pfile->max_include_len)
358 pfile->max_include_len = len;
360 new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list));
363 new->ino = st.st_ino;
364 new->dev = st.st_dev;
366 new->sysp = cxx_aware ? 1 : 2;
369 new->name_map = NULL;
375 case QUOTE: APPEND (pend, quote, new); break;
376 case BRACKET: APPEND (pend, brack, new); break;
377 case SYSTEM: APPEND (pend, systm, new); break;
378 case AFTER: APPEND (pend, after, new); break;
382 /* Merge the four include chains together in the order quote, bracket,
383 system, after. Remove duplicate dirs (as determined by
384 INO_T_EQ()). The system_include and after_include chains are never
385 referred to again after this function; all access is through the
386 bracket_include path.
388 For the future: Check if the directory is empty (but
389 how?) and possibly preload the include hash. */
392 merge_include_chains (opts)
393 struct cpp_options *opts;
395 struct file_name_list *prev, *cur, *other;
396 struct file_name_list *quote, *brack, *systm, *after;
397 struct file_name_list *qtail, *btail, *stail, *atail;
399 qtail = opts->pending->quote_tail;
400 btail = opts->pending->brack_tail;
401 stail = opts->pending->systm_tail;
402 atail = opts->pending->after_tail;
404 quote = opts->pending->quote_head;
405 brack = opts->pending->brack_head;
406 systm = opts->pending->systm_head;
407 after = opts->pending->after_head;
409 /* Paste together bracket, system, and after include chains. */
419 /* This is a bit tricky.
420 First we drop dupes from the quote-include list.
421 Then we drop dupes from the bracket-include list.
422 Finally, if qtail and brack are the same directory,
425 We can't just merge the lists and then uniquify them because
426 then we may lose directories from the <> search path that should
427 be there; consider -Ifoo -Ibar -I- -Ifoo -Iquux. It is however
428 safe to treat -Ibar -Ifoo -I- -Ifoo -Iquux as if written
429 -Ibar -I- -Ifoo -Iquux.
431 Note that this algorithm is quadratic in the number of -I switches,
432 which is acceptable since there aren't usually that many of them. */
434 for (cur = quote, prev = NULL; cur; cur = cur->next)
436 for (other = quote; other != cur; other = other->next)
437 if (INO_T_EQ (cur->ino, other->ino)
438 && cur->dev == other->dev)
441 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
444 prev->next = cur->next;
454 for (cur = brack; cur; cur = cur->next)
456 for (other = brack; other != cur; other = other->next)
457 if (INO_T_EQ (cur->ino, other->ino)
458 && cur->dev == other->dev)
461 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
464 prev->next = cur->next;
475 if (INO_T_EQ (qtail->ino, brack->ino) && qtail->dev == brack->dev)
480 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
490 while (cur->next != qtail)
494 fprintf (stderr, _("ignoring duplicate directory `%s'\n"),
507 opts->quote_include = quote;
508 opts->bracket_include = brack;
512 /* Write out a #define command for the special named MACRO_NAME
513 to PFILE's token_buffer. */
516 dump_special_to_buffer (pfile, macro_name)
518 const char *macro_name;
520 static const char define_directive[] = "#define ";
521 int macro_name_length = strlen (macro_name);
522 _cpp_output_line_command (pfile, same_file);
523 CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length);
524 CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1);
525 CPP_PUTS_Q (pfile, macro_name, macro_name_length);
526 CPP_PUTC_Q (pfile, ' ');
527 cpp_expand_to_buffer (pfile, macro_name, macro_name_length);
528 CPP_PUTC (pfile, '\n');
531 /* Initialize a cpp_options structure. */
533 cpp_options_init (opts)
536 memset ((char *) opts, 0, sizeof (struct cpp_options));
538 opts->dollars_in_ident = 1;
539 opts->cplusplus_comments = 1;
540 opts->warn_import = 1;
541 opts->discard_comments = 1;
544 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
547 /* Initialize a cpp_reader structure. */
549 cpp_reader_init (pfile)
552 memset ((char *) pfile, 0, sizeof (cpp_reader));
554 pfile->token_buffer_size = 200;
555 pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
556 CPP_SET_WRITTEN (pfile, 0);
558 _cpp_init_macro_hash (pfile);
559 _cpp_init_include_hash (pfile);
562 /* Free resources used by PFILE.
563 This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology). */
568 while (CPP_BUFFER (pfile) != NULL)
569 cpp_pop_buffer (pfile);
571 if (pfile->token_buffer)
573 free (pfile->token_buffer);
574 pfile->token_buffer = NULL;
577 if (pfile->input_buffer)
579 free (pfile->input_buffer);
580 free (pfile->input_speccase);
581 pfile->input_buffer = pfile->input_speccase = NULL;
582 pfile->input_buffer_len = 0;
586 deps_free (pfile->deps);
588 htab_delete (pfile->hashtab);
589 htab_delete (pfile->all_include_files);
593 /* This structure defines one built-in macro. A node of type TYPE will
594 be entered in the macro hash table under the name NAME, with value
595 VALUE (if any). FLAGS tweaks the behavior a little:
596 DUMP write debug info for this macro
597 STDC define only if not -traditional
598 ULP value is the global user_label_prefix (which can't be
599 put directly into the table).
607 unsigned short flags;
614 static const struct builtin builtin_array[] =
616 { "__TIME__", 0, T_TIME, DUMP },
617 { "__DATE__", 0, T_DATE, DUMP },
618 { "__FILE__", 0, T_FILE, 0 },
619 { "__BASE_FILE__", 0, T_BASE_FILE, 0 },
620 { "__LINE__", 0, T_SPECLINE, 0 },
621 { "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL, 0 },
622 { "__VERSION__", 0, T_VERSION, DUMP|VERS },
623 { "__STDC__", 0, T_STDC, DUMP|STDC },
625 { "__USER_LABEL_PREFIX__", 0, T_CONST, ULP },
626 { "__REGISTER_PREFIX__", REGISTER_PREFIX, T_CONST, 0 },
627 { "__HAVE_BUILTIN_SETJMP__", "1", T_CONST, 0 },
628 #ifndef NO_BUILTIN_SIZE_TYPE
629 { "__SIZE_TYPE__", SIZE_TYPE, T_CONST, DUMP },
631 #ifndef NO_BUILTIN_PTRDIFF_TYPE
632 { "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP },
634 #ifndef NO_BUILTIN_WCHAR_TYPE
635 { "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP },
640 /* Subroutine of cpp_start_read; reads the builtins table above and
641 enters the macros into the hash table. */
643 initialize_builtins (pfile)
647 const struct builtin *b;
650 for(b = builtin_array; b->name; b++)
652 if ((b->flags & STDC) && CPP_TRADITIONAL (pfile))
656 val = user_label_prefix;
657 else if (b->flags & VERS)
658 val = version_string;
662 len = strlen (b->name);
663 hp = _cpp_make_hashnode (b->name, len, b->type, -1);
664 hp->value.cpval = val;
665 *(htab_find_slot (pfile->hashtab, (void *)hp, 1)) = hp;
667 if ((b->flags & DUMP) && CPP_OPTIONS (pfile)->debug_output)
668 dump_special_to_buffer (pfile, b->name);
677 /* Another subroutine of cpp_start_read. This one sets up to do
678 dependency-file output. */
680 initialize_dependency_output (pfile)
683 cpp_options *opts = CPP_OPTIONS (pfile);
684 char *spec, *s, *output_file;
686 /* Either of two environment variables can specify output of deps.
687 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
688 where OUTPUT_FILE is the file to write deps info to
689 and DEPS_TARGET is the target to mention in the deps. */
691 if (opts->print_deps == 0)
693 spec = getenv ("DEPENDENCIES_OUTPUT");
695 opts->print_deps = 1;
698 spec = getenv ("SUNPRO_DEPENDENCIES");
700 opts->print_deps = 2;
705 /* Find the space before the DEPS_TARGET, if there is one. */
706 s = strchr (spec, ' ');
709 opts->deps_target = s + 1;
710 output_file = (char *) xmalloc (s - spec + 1);
711 memcpy (output_file, spec, s - spec);
712 output_file[s - spec] = 0;
716 opts->deps_target = 0;
720 opts->deps_file = output_file;
721 opts->print_deps_append = 1;
724 pfile->deps = deps_init ();
726 /* Print the expected object file name as the target of this Make-rule. */
727 if (opts->deps_target)
728 deps_add_target (pfile->deps, opts->deps_target);
729 else if (*opts->in_fname == 0)
730 deps_add_target (pfile->deps, "-");
732 deps_calc_target (pfile->deps, opts->in_fname);
735 deps_add_dep (pfile->deps, opts->in_fname);
738 /* And another subroutine. This one sets up the standard include path. */
740 initialize_standard_includes (pfile)
743 cpp_options *opts = CPP_OPTIONS (pfile);
745 const struct default_include *p;
746 const char *specd_prefix = opts->include_prefix;
748 /* Several environment variables may add to the include search path.
749 CPATH specifies an additional list of directories to be searched
750 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
751 etc. specify an additional list of directories to be searched as
752 if specified with -isystem, for the language indicated. */
754 GET_ENV_PATH_LIST (path, "CPATH");
755 if (path != 0 && *path != 0)
756 path_include (pfile, opts->pending, path, BRACKET);
758 switch ((opts->objc << 1) + opts->cplusplus)
761 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
764 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
767 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
770 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
773 if (path != 0 && *path != 0)
774 path_include (pfile, opts->pending, path, SYSTEM);
776 /* Search "translated" versions of GNU directories.
777 These have /usr/local/lib/gcc... replaced by specd_prefix. */
778 if (specd_prefix != 0)
780 char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7);
781 /* Remove the `include' from /usr/local/lib/gcc.../include.
782 GCC_INCLUDE_DIR will always end in /include. */
783 int default_len = sizeof GCC_INCLUDE_DIR - 8;
784 int specd_len = strlen (specd_prefix);
786 memcpy (default_prefix, GCC_INCLUDE_DIR, default_len);
787 default_prefix[default_len] = '\0';
789 for (p = include_defaults_array; p->fname; p++)
791 /* Some standard dirs are only for C++. */
794 && !opts->no_standard_cplusplus_includes))
796 /* Does this dir start with the prefix? */
797 if (!strncmp (p->fname, default_prefix, default_len))
799 /* Yes; change prefix and add to search list. */
800 int flen = strlen (p->fname);
801 int this_len = specd_len + flen - default_len;
802 char *str = (char *) xmalloc (this_len + 1);
803 memcpy (str, specd_prefix, specd_len);
804 memcpy (str + specd_len,
805 p->fname + default_len,
806 flen - default_len + 1);
808 append_include_chain (pfile, opts->pending,
809 str, SYSTEM, p->cxx_aware);
815 /* Search ordinary names for GNU include directories. */
816 for (p = include_defaults_array; p->fname; p++)
818 /* Some standard dirs are only for C++. */
821 && !opts->no_standard_cplusplus_includes))
823 /* XXX Potential memory leak! */
824 char *str = xstrdup (update_path (p->fname, p->component));
825 append_include_chain (pfile, opts->pending, str, SYSTEM,
831 /* This is called after options have been processed.
832 * Check options for consistency, and setup for processing input
833 * from the file named FNAME. (Use standard input if FNAME==NULL.)
834 * Return 1 on success, 0 on failure.
838 cpp_start_read (pfile, fname)
842 struct cpp_options *opts = CPP_OPTIONS (pfile);
843 struct pending_option *p, *q;
845 /* -MG doesn't select the form of output and must be specified with one of
846 -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
847 inhibit compilation. */
848 if (opts->print_deps_missing_files
849 && (opts->print_deps == 0 || !opts->no_output))
851 cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
855 /* Chill should not be used with -trigraphs. */
856 if (opts->chill && opts->trigraphs)
858 cpp_warning (pfile, "-lang-chill and -trigraphs are mutually exclusive");
862 /* Set this if it hasn't been set already. */
863 if (user_label_prefix == NULL)
864 user_label_prefix = USER_LABEL_PREFIX;
866 /* Don't bother trying to do macro expansion if we've already done
868 if (opts->preprocessed)
869 pfile->no_macro_expand++;
871 /* Set up the IStable. This doesn't do anything if we were compiled
872 with a compiler that supports C99 designated initializers. */
875 /* Set up the tables used by read_and_prescan. */
876 _cpp_init_input_buffer (pfile);
878 /* Set up the include search path now. */
879 if (! opts->no_standard_includes)
880 initialize_standard_includes (pfile);
882 merge_include_chains (opts);
884 /* With -v, print the list of dirs to search. */
887 struct file_name_list *l;
888 fprintf (stderr, _("#include \"...\" search starts here:\n"));
889 for (l = opts->quote_include; l; l = l->next)
891 if (l == opts->bracket_include)
892 fprintf (stderr, _("#include <...> search starts here:\n"));
893 fprintf (stderr, " %s\n", l->name);
895 fprintf (stderr, _("End of search list.\n"));
898 initialize_dependency_output (pfile);
900 /* Open the main input file. This must be done before -D processing
901 so we have a buffer to stand on. */
902 if (opts->in_fname == NULL || *opts->in_fname == 0)
904 opts->in_fname = fname;
905 if (opts->in_fname == NULL)
909 if (!cpp_read_file (pfile, fname))
912 /* -D and friends may produce output, which should be identified
915 CPP_BUFFER (pfile)->lineno = 0;
917 /* Install __LINE__, etc. */
918 initialize_builtins (pfile);
920 /* Do -U's, -D's and -A's in the order they were seen. */
921 p = opts->pending->directive_head;
924 (*p->handler) (pfile, p->arg);
930 opts->done_initializing = 1;
931 CPP_BUFFER (pfile)->lineno = 1;
933 if (opts->preprocessed)
934 /* If we've already processed this code, we want to trust the #line
935 directives in the input. But we still need to update our line
936 counter accordingly. */
937 pfile->lineno = CPP_BUFFER (pfile)->lineno;
939 _cpp_output_line_command (pfile, same_file);
940 pfile->only_seen_white = 2;
942 /* The -imacros files can be scanned now, but the -include files
943 have to be pushed onto the include stack and processed later,
944 in the main loop calling cpp_get_token. */
947 p = opts->pending->imacros_head;
950 if (cpp_read_file (pfile, p->arg))
951 cpp_scan_buffer (pfile);
959 p = opts->pending->include_head;
962 if (cpp_read_file (pfile, p->arg))
963 _cpp_output_line_command (pfile, enter_file);
970 free (opts->pending);
971 opts->pending = NULL;
976 /* This is called at the end of preprocessing. It pops the
977 last buffer and writes dependency output. It should also
978 clear macro definitions, such that you could call cpp_start_read
979 with a new filename to restart processing. */
984 struct cpp_options *opts = CPP_OPTIONS (pfile);
986 if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)))
987 cpp_ice (pfile, "buffers still stacked in cpp_finish");
988 while (CPP_BUFFER (pfile))
989 cpp_pop_buffer (pfile);
991 /* Don't write the deps file if preprocessing has failed. */
992 if (opts->print_deps && pfile->errors == 0)
994 /* Stream on which to print the dependency information. */
995 FILE *deps_stream = 0;
997 const char *deps_mode = opts->print_deps_append ? "a" : "w";
998 if (opts->deps_file == 0)
999 deps_stream = stdout;
1000 else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0)
1001 cpp_notice_from_errno (pfile, opts->deps_file);
1005 deps_write (pfile->deps, deps_stream, 72);
1006 if (opts->deps_file)
1008 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1009 cpp_fatal (pfile, "I/O error on output");
1014 if (opts->dump_macros == dump_only)
1015 _cpp_dump_macro_hash (pfile);
1019 new_pending_directive (opts, text, handler)
1020 struct cpp_options *opts;
1022 cl_directive_handler handler;
1024 struct pending_option *o = (struct pending_option *)
1025 xmalloc (sizeof (struct pending_option));
1029 o->handler = handler;
1030 APPEND (opts->pending, directive, o);
1035 OPT_stdin_stdout = 0, OPT_dollar, OPT_plus,
1036 OPT__help, OPT__version,
1037 OPT_A, OPT_C, OPT_D, OPT_H, OPT_I, OPT_M,
1038 OPT_MD, OPT_MG, OPT_MM, OPT_MMD,
1039 OPT_P, OPT_U, OPT_W,
1041 OPT_fleading_underscore, OPT_fno_leading_underscore,
1042 OPT_fpreprocessed, OPT_fno_preprocessed,
1044 OPT_idirafter, OPT_imacros, OPT_include,
1045 OPT_iprefix, OPT_isystem, OPT_iwithprefix, OPT_iwithprefixbefore,
1046 OPT_lang_asm, OPT_lang_c, OPT_lang_cplusplus, OPT_lang_c89,
1047 OPT_lang_chill, OPT_lang_fortran, OPT_lang_objc, OPT_lang_objcplusplus,
1048 OPT_nostdinc, OPT_nostdincplusplus,
1050 OPT_pedantic, OPT_pedantic_errors, OPT_remap,
1051 OPT_std_c89, OPT_std_c99, OPT_std_c9x, OPT_std_gnu89, OPT_std_gnu99,
1052 OPT_std_gnu9x, OPT_std_iso9899_1990, OPT_std_iso9899_199409,
1053 OPT_std_iso9899_1999, OPT_std_iso9899_199x,
1054 OPT_traditional, OPT_trigraphs,
1061 const char *opt_text;
1064 enum opt_code opt_code;
1067 /* Irix6 "cc -n32" and OSF4 cc have problems with char foo[] = ("string");
1068 I.e. a const string initializer with parens around it. That is
1069 what N_("string") resolves to, so we make no_* be macros instead. */
1070 #define no_arg N_("Argument missing after `%s' option")
1071 #define no_ass N_("Assertion missing after `%s' option")
1072 #define no_dir N_("Directory name missing after `%s' option")
1073 #define no_fil N_("File name missing after `%s' option")
1074 #define no_mac N_("Macro name missing after `%s' option")
1075 #define no_pth N_("Path name missing after `%s' option")
1077 /* This list must be ASCII sorted. Make enum order above match this. */
1078 #define DEF_OPT(text, msg, code) {text, msg, sizeof(text) - 1, code}
1081 static struct cl_option cl_options[] =
1083 static const struct cl_option cl_options[] =
1086 DEF_OPT("", 0, OPT_stdin_stdout),
1087 DEF_OPT("$", 0, OPT_dollar),
1088 DEF_OPT("+", 0, OPT_plus),
1089 DEF_OPT("-help", 0, OPT__help),
1090 DEF_OPT("-version", 0, OPT__version),
1091 DEF_OPT("A", no_ass, OPT_A),
1092 DEF_OPT("C", 0, OPT_C),
1093 DEF_OPT("D", no_mac, OPT_D),
1094 DEF_OPT("H", 0, OPT_H),
1095 DEF_OPT("I", no_dir, OPT_I),
1096 DEF_OPT("M", 0, OPT_M),
1097 DEF_OPT("MD", no_fil, OPT_MD),
1098 DEF_OPT("MG", 0, OPT_MG),
1099 DEF_OPT("MM", 0, OPT_MM),
1100 DEF_OPT("MMD", no_fil, OPT_MMD),
1101 DEF_OPT("P", 0, OPT_P),
1102 DEF_OPT("U", no_mac, OPT_U),
1103 /* NB: Immed arg only, and not reqd */
1104 DEF_OPT("W", no_arg, OPT_W),
1105 DEF_OPT("d", no_arg, OPT_d),
1106 DEF_OPT("fleading-underscore", 0, OPT_fleading_underscore),
1107 DEF_OPT("fno-leading-underscore", 0, OPT_fno_leading_underscore),
1108 DEF_OPT("fpreprocessed", 0, OPT_fpreprocessed),
1109 DEF_OPT("fno-preprocessed", 0, OPT_fno_preprocessed),
1110 /* NB: Immed arg only, and not reqd */
1111 DEF_OPT("g", no_arg, OPT_g),
1112 DEF_OPT("h", 0, OPT_h),
1113 DEF_OPT("idirafter", no_dir, OPT_idirafter),
1114 DEF_OPT("imacros", no_fil, OPT_imacros),
1115 DEF_OPT("include", no_fil, OPT_include),
1116 DEF_OPT("iprefix", no_pth, OPT_iprefix),
1117 DEF_OPT("isystem", no_dir, OPT_isystem),
1118 DEF_OPT("iwithprefix", no_dir, OPT_iwithprefix),
1119 DEF_OPT("iwithprefixbefore", no_dir, OPT_iwithprefixbefore),
1120 DEF_OPT("lang-asm", 0, OPT_lang_asm),
1121 DEF_OPT("lang-c", 0, OPT_lang_c),
1122 DEF_OPT("lang-c++", 0, OPT_lang_cplusplus),
1123 DEF_OPT("lang-c89", 0, OPT_lang_c89),
1124 DEF_OPT("lang-chill", 0, OPT_lang_chill),
1125 DEF_OPT("lang-fortran", 0, OPT_lang_fortran),
1126 DEF_OPT("lang-objc", 0, OPT_lang_objc),
1127 DEF_OPT("lang-objc++", 0, OPT_lang_objcplusplus),
1128 DEF_OPT("nostdinc", 0, OPT_nostdinc),
1129 DEF_OPT("nostdinc++", 0, OPT_nostdincplusplus),
1130 DEF_OPT("o", no_fil, OPT_o),
1131 DEF_OPT("pedantic", 0, OPT_pedantic),
1132 DEF_OPT("pedantic-errors", 0, OPT_pedantic_errors),
1133 DEF_OPT("remap", 0, OPT_remap),
1134 DEF_OPT("std=c89", 0, OPT_std_c89),
1135 DEF_OPT("std=c99", 0, OPT_std_c99),
1136 DEF_OPT("std=c9x", 0, OPT_std_c9x),
1137 DEF_OPT("std=gnu89", 0, OPT_std_gnu89),
1138 DEF_OPT("std=gnu99", 0, OPT_std_gnu99),
1139 DEF_OPT("std=gnu9x", 0, OPT_std_gnu9x),
1140 DEF_OPT("std=iso9899:1990", 0, OPT_std_iso9899_1990),
1141 DEF_OPT("std=iso9899:199409", 0, OPT_std_iso9899_199409),
1142 DEF_OPT("std=iso9899:1999", 0, OPT_std_iso9899_1999),
1143 DEF_OPT("std=iso9899:199x", 0, OPT_std_iso9899_199x),
1144 DEF_OPT("traditional", 0, OPT_traditional),
1145 DEF_OPT("trigraphs", 0, OPT_trigraphs),
1146 DEF_OPT("v", 0, OPT_v),
1147 DEF_OPT("w", 0, OPT_w)
1151 /* Perform a binary search to find which, if any, option the given
1152 command-line matches. Returns its index in the option array,
1153 negative on failure. Complications arise since some options can be
1154 suffixed with an argument, and multiple complete matches can occur,
1155 e.g. -iwithprefix and -iwithprefixbefore. Moreover, we want to
1156 accept options beginning with -g and -W that we do not recognise,
1157 but not to swallow any subsequent command line argument; these are
1158 handled as special cases in cpp_handle_option */
1160 parse_option (input)
1163 unsigned int md, mn, mx;
1174 opt_len = cl_options[md].opt_len;
1175 comp = strncmp (input, cl_options[md].opt_text, opt_len);
1183 if (input[opt_len] == '\0')
1185 /* We were passed more text. If the option takes an argument,
1186 we may match a later option or we may have been passed the
1187 argument. The longest possible option match succeeds.
1188 If the option takes no arguments we have not matched and
1189 continue the search (e.g. input="stdc++" match was "stdc") */
1191 if (cl_options[md].msg)
1193 /* Scan forwards. If we get an exact match, return it.
1194 Otherwise, return the longest option-accepting match.
1195 This loops no more than twice with current options */
1197 for (; mn < N_OPTS; mn++)
1199 opt_len = cl_options[mn].opt_len;
1200 if (strncmp (input, cl_options[mn].opt_text, opt_len))
1202 if (input[opt_len] == '\0')
1204 if (cl_options[mn].msg)
1215 /* Handle one command-line option in (argc, argv).
1216 Can be called multiple times, to handle multiple sets of options.
1217 Returns number of strings consumed. */
1220 handle_option (pfile, argc, argv)
1225 struct cpp_options *opts = CPP_OPTIONS (pfile);
1228 if (argv[i][0] != '-')
1230 if (opts->out_fname != NULL)
1233 cpp_fatal (pfile, "Too many arguments");
1235 else if (opts->in_fname != NULL)
1236 opts->out_fname = argv[i];
1238 opts->in_fname = argv[i];
1242 enum opt_code opt_code;
1244 const char *arg = 0;
1247 opt_index = parse_option (&argv[i][1]);
1251 opt_code = cl_options[opt_index].opt_code;
1252 if (cl_options[opt_index].msg)
1254 arg = &argv[i][cl_options[opt_index].opt_len + 1];
1256 /* Yuk. Special case for -g and -W as they must not swallow
1257 up any following argument. If this becomes common, add
1258 another field to the cl_options table */
1259 if (arg[0] == '\0' && !(opt_code == OPT_g || opt_code == OPT_W))
1264 cpp_fatal (pfile, _(cl_options[opt_index].msg), argv[i - 1]);
1272 case N_OPTS: /* shut GCC up */
1274 case OPT_fleading_underscore:
1275 user_label_prefix = "_";
1277 case OPT_fno_leading_underscore:
1278 user_label_prefix = "";
1280 case OPT_fpreprocessed:
1281 opts->preprocessed = 1;
1283 case OPT_fno_preprocessed:
1284 opts->preprocessed = 0;
1287 opts->inhibit_warnings = 1;
1289 case OPT_g: /* Silently ignore anything but -g3 */
1290 if (!strcmp(&argv[i][2], "3"))
1291 opts->debug_output = 1;
1299 fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
1303 opts->discard_comments = 0;
1306 opts->no_line_commands = 1;
1308 case OPT_dollar: /* Don't include $ in identifiers. */
1309 opts->dollars_in_ident = 0;
1312 opts->print_include_names = 1;
1315 new_pending_directive (opts, arg, cpp_define);
1317 case OPT_pedantic_errors:
1318 opts->pedantic_errors = 1;
1323 case OPT_traditional:
1324 opts->traditional = 1;
1325 opts->cplusplus_comments = 0;
1326 opts->trigraphs = 0;
1327 opts->warn_trigraphs = 0;
1330 opts->trigraphs = 1;
1333 opts->cplusplus = 1;
1334 opts->cplusplus_comments = 1;
1340 opts->include_prefix = arg;
1341 opts->include_prefix_len = strlen (arg);
1344 opts->cplusplus = 0, opts->cplusplus_comments = 1;
1345 opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
1348 opts->cplusplus = 0, opts->cplusplus_comments = 0;
1349 opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
1350 opts->trigraphs = 1;
1351 new_pending_directive (opts, "__STRICT_ANSI__", cpp_define);
1353 case OPT_lang_cplusplus:
1354 opts->cplusplus = 1, opts->cplusplus_comments = 1;
1355 opts->c89 = 0, opts->c99 = 0, opts->objc = 0;
1358 case OPT_lang_objcplusplus:
1359 opts->cplusplus = opt_code == OPT_lang_objcplusplus;
1360 opts->cplusplus_comments = 1;
1361 opts->c89 = 0, opts->c99 = 0, opts->objc = 1;
1366 case OPT_lang_fortran:
1367 opts->lang_fortran = 1, opts->cplusplus_comments = 0;
1369 case OPT_lang_chill:
1370 opts->objc = 0, opts->cplusplus = 0;
1371 opts->chill = 1, opts->traditional = 1;
1374 /* -nostdinc causes no default include directories.
1375 You must specify all include-file directories with -I. */
1376 opts->no_standard_includes = 1;
1378 case OPT_nostdincplusplus:
1379 /* -nostdinc++ causes no default C++-specific include directories. */
1380 opts->no_standard_cplusplus_includes = 1;
1383 opts->cplusplus = 0, opts->cplusplus_comments = 1;
1384 opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
1388 opts->cplusplus = 0, opts->cplusplus_comments = 1;
1389 opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
1390 new_pending_directive (opts, "__STDC_VERSION__=199901L", cpp_define);
1392 case OPT_std_iso9899_199409:
1393 new_pending_directive (opts, "__STDC_VERSION__=199409L", cpp_define);
1395 case OPT_std_iso9899_1990:
1397 opts->cplusplus = 0, opts->cplusplus_comments = 0;
1398 opts->c89 = 1, opts->c99 = 0, opts->objc = 0;
1399 opts->trigraphs = 1;
1400 new_pending_directive (opts, "__STRICT_ANSI__", cpp_define);
1402 case OPT_std_iso9899_199x:
1403 case OPT_std_iso9899_1999:
1406 opts->cplusplus = 0, opts->cplusplus_comments = 1;
1407 opts->c89 = 0, opts->c99 = 1, opts->objc = 0;
1408 opts->trigraphs = 1;
1409 new_pending_directive (opts, "__STRICT_ANSI__", cpp_define);
1410 new_pending_directive (opts, "__STDC_VERSION__=199901L", cpp_define);
1413 if (opts->out_fname != NULL)
1415 cpp_fatal (pfile, "Output filename specified twice");
1418 opts->out_fname = arg;
1419 if (!strcmp (opts->out_fname, "-"))
1420 opts->out_fname = "";
1423 fprintf (stderr, _("GNU CPP version %s (cpplib)\n"), version_string);
1424 #ifdef TARGET_VERSION
1427 fputc ('\n', stderr);
1430 case OPT_stdin_stdout:
1431 /* JF handle '-' as file name meaning stdin or stdout */
1432 if (opts->in_fname == NULL)
1433 opts->in_fname = "";
1434 else if (opts->out_fname == NULL)
1435 opts->out_fname = "";
1438 /* Args to -d specify what parts of macros to dump.
1439 Silently ignore unrecognised options; they may
1440 be aimed at the compiler proper. */
1444 while ((c = *arg++) != '\0')
1448 opts->dump_macros = dump_only;
1449 opts->no_output = 1;
1452 opts->dump_macros = dump_names;
1455 opts->dump_macros = dump_definitions;
1458 opts->dump_includes = 1;
1463 /* The style of the choices here is a bit mixed.
1464 The chosen scheme is a hybrid of keeping all options in one string
1465 and specifying each option in a separate argument:
1466 -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
1467 -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
1468 -M[M][G][D file]. This is awkward to handle in specs, and is not
1470 /* ??? -MG must be specified in addition to one of -M or -MM.
1471 This can be relaxed in the future without breaking anything.
1472 The converse isn't true. */
1474 /* -MG isn't valid with -MD or -MMD. This is checked for later. */
1476 opts->print_deps_missing_files = 1;
1482 if (opt_code == OPT_M || opt_code == OPT_MD)
1483 opts->print_deps = 2;
1485 opts->print_deps = 1;
1487 /* For -MD and -MMD options, write deps on file named by next arg */
1488 /* For -M and -MM, write deps on standard output
1489 and suppress the usual output. */
1490 if (opt_code == OPT_MD || opt_code == OPT_MMD)
1491 opts->deps_file = arg;
1493 opts->no_output = 1;
1498 /* -A with an argument beginning with '-' acts as
1499 #unassert on whatever immediately follows the '-'.
1500 If "-" is the whole argument, we eliminate all
1501 predefined macros and assertions, including those
1502 that were specified earlier on the command line.
1503 That way we can get rid of any that were passed
1504 automatically in from GCC. */
1508 struct pending_option *o1, *o2;
1510 o1 = opts->pending->directive_head;
1517 opts->pending->directive_head = NULL;
1518 opts->pending->directive_tail = NULL;
1521 new_pending_directive (opts, arg + 1, cpp_unassert);
1524 new_pending_directive (opts, arg, cpp_assert);
1527 new_pending_directive (opts, arg, cpp_undef);
1529 case OPT_I: /* Add directory to path for includes. */
1530 if (!strcmp (arg, "-"))
1533 Use the preceding -I directories for #include "..."
1534 but not #include <...>.
1535 Don't search the directory of the present file
1536 for #include "...". (Note that -I. -I- is not the same as
1537 the default setup; -I. uses the compiler's working dir.) */
1538 if (! opts->ignore_srcdir)
1540 opts->ignore_srcdir = 1;
1541 opts->pending->quote_head = opts->pending->brack_head;
1542 opts->pending->quote_tail = opts->pending->brack_tail;
1543 opts->pending->brack_head = 0;
1544 opts->pending->brack_tail = 0;
1548 cpp_fatal (pfile, "-I- specified twice");
1553 append_include_chain (pfile, opts->pending,
1554 xstrdup (arg), BRACKET, 0);
1557 /* Add directory to beginning of system include path, as a system
1558 include directory. */
1559 append_include_chain (pfile, opts->pending,
1560 xstrdup (arg), SYSTEM, 0);
1564 struct pending_option *o = (struct pending_option *)
1565 xmalloc (sizeof (struct pending_option));
1568 /* This list has to be built in reverse order so that
1569 when cpp_start_read pushes all the -include files onto
1570 the buffer stack, they will be scanned in forward order. */
1571 o->next = opts->pending->include_head;
1572 opts->pending->include_head = o;
1577 struct pending_option *o = (struct pending_option *)
1578 xmalloc (sizeof (struct pending_option));
1582 APPEND (opts->pending, imacros, o);
1585 case OPT_iwithprefix:
1586 /* Add directory to end of path for includes,
1587 with the default prefix at the front of its name. */
1589 case OPT_iwithprefixbefore:
1590 /* Add directory to main path for includes,
1591 with the default prefix at the front of its name. */
1598 if (opts->include_prefix != 0)
1600 fname = xmalloc (opts->include_prefix_len + len + 1);
1601 memcpy (fname, opts->include_prefix, opts->include_prefix_len);
1602 memcpy (fname + opts->include_prefix_len, arg, len + 1);
1606 fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
1607 memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
1608 memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, arg, len + 1);
1611 append_include_chain (pfile, opts->pending, fname,
1612 opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);
1616 /* Add directory to end of path for includes. */
1617 append_include_chain (pfile, opts->pending,
1618 xstrdup (arg), AFTER, 0);
1621 /* Silently ignore unrecognised options */
1622 if (!strcmp (argv[i], "-Wall"))
1624 opts->warn_trigraphs = 1;
1625 opts->warn_comments = 1;
1627 else if (!strcmp (argv[i], "-Wtraditional"))
1628 opts->warn_stringify = 1;
1629 else if (!strcmp (argv[i], "-Wtrigraphs"))
1630 opts->warn_trigraphs = 1;
1631 else if (!strcmp (argv[i], "-Wcomment"))
1632 opts->warn_comments = 1;
1633 else if (!strcmp (argv[i], "-Wcomments"))
1634 opts->warn_comments = 1;
1635 else if (!strcmp (argv[i], "-Wundef"))
1636 opts->warn_undef = 1;
1637 else if (!strcmp (argv[i], "-Wimport"))
1638 opts->warn_import = 1;
1639 else if (!strcmp (argv[i], "-Werror"))
1640 opts->warnings_are_errors = 1;
1641 else if (!strcmp (argv[i], "-Wno-traditional"))
1642 opts->warn_stringify = 0;
1643 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1644 opts->warn_trigraphs = 0;
1645 else if (!strcmp (argv[i], "-Wno-comment"))
1646 opts->warn_comments = 0;
1647 else if (!strcmp (argv[i], "-Wno-comments"))
1648 opts->warn_comments = 0;
1649 else if (!strcmp (argv[i], "-Wno-undef"))
1650 opts->warn_undef = 0;
1651 else if (!strcmp (argv[i], "-Wno-import"))
1652 opts->warn_import = 0;
1653 else if (!strcmp (argv[i], "-Wno-error"))
1654 opts->warnings_are_errors = 0;
1663 opt_comp (const void *p1, const void *p2)
1665 return strcmp (((struct cl_option *)p1)->opt_text,
1666 ((struct cl_option *)p2)->opt_text);
1670 /* Handle command-line options in (argc, argv).
1671 Can be called multiple times, to handle multiple sets of options.
1672 Returns if an unrecognized option is seen.
1673 Returns number of strings consumed. */
1675 cpp_handle_options (pfile, argc, argv)
1681 int strings_processed;
1684 static int opts_sorted = 0;
1689 /* For non-ASCII hosts, the array needs to be sorted at runtime */
1690 qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
1694 for (i = 0; i < argc; i += strings_processed)
1696 strings_processed = handle_option (pfile, argc - i, argv + i);
1697 if (strings_processed == 0)
1706 fprintf (stderr, _("Usage: %s [switches] input output\n"), progname);
1709 -include <file> Include the contents of <file> before other files\n\
1710 -imacros <file> Accept definition of macros in <file>\n\
1711 -iprefix <path> Specify <path> as a prefix for next two options\n\
1712 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1713 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1714 -isystem <dir> Add <dir> to the start of the system include path\n\
1715 -idirafter <dir> Add <dir> to the end of the system include path\n\
1716 -I <dir> Add <dir> to the end of the main include path\n\
1717 -I- Fine-grained include path control; see info docs\n\
1718 -nostdinc Do not search system include directories\n\
1719 (dirs specified with -isystem will still be used)\n\
1720 -nostdinc++ Do not search system include directories for C++\n\
1721 -o <file> Put output into <file>\n\
1722 -pedantic Issue all warnings demanded by strict ANSI C\n\
1723 -pedantic-errors Issue -pedantic warnings as errors instead\n\
1724 -traditional Follow K&R pre-processor behaviour\n\
1725 -trigraphs Support ANSI C trigraphs\n\
1726 -lang-c Assume that the input sources are in C\n\
1727 -lang-c89 Assume that the input sources are in C89\n\
1728 -lang-c++ Assume that the input sources are in C++\n\
1729 -lang-objc Assume that the input sources are in ObjectiveC\n\
1730 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1731 -lang-asm Assume that the input sources are in assembler\n\
1732 -lang-fortran Assume that the input sources are in Fortran\n\
1733 -lang-chill Assume that the input sources are in Chill\n\
1734 -std=<std name> Specify the conformance standard; one of:\n\
1735 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1736 iso9899:199409, iso9899:1999\n\
1737 -+ Allow parsing of C++ style features\n\
1738 -w Inhibit warning messages\n\
1739 -Wtrigraphs Warn if trigraphs are encountered\n\
1740 -Wno-trigraphs Do not warn about trigraphs\n\
1741 -Wcomment{s} Warn if one comment starts inside another\n\
1742 -Wno-comment{s} Do not warn about comments\n\
1743 -Wtraditional Warn if a macro argument is/would be turned into\n\
1744 a string if -traditional is specified\n\
1745 -Wno-traditional Do not warn about stringification\n\
1746 -Wundef Warn if an undefined macro is used by #if\n\
1747 -Wno-undef Do not warn about testing undefined macros\n\
1748 -Wimport Warn about the use of the #import directive\n\
1749 -Wno-import Do not warn about the use of #import\n\
1750 -Werror Treat all warnings as errors\n\
1751 -Wno-error Do not treat warnings as errors\n\
1752 -Wall Enable all preprocessor warnings\n\
1753 -M Generate make dependencies\n\
1754 -MM As -M, but ignore system header files\n\
1755 -MD As -M, but put output in a .d file\n\
1756 -MMD As -MD, but ignore system header files\n\
1757 -MG Treat missing header file as generated files\n\
1758 -g3 Include #define and #undef directives in the output\n\
1759 -D<macro> Define a <macro> with string '1' as its value\n\
1760 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1761 -A<question> (<answer>) Assert the <answer> to <question>\n\
1762 -A-<question> (<answer>) Disable the <answer> to <question>\n\
1763 -U<macro> Undefine <macro> \n\
1764 -v Display the version number\n\
1765 -H Print the name of header files as they are used\n\
1766 -C Do not discard comments\n\
1767 -dM Display a list of macro definitions active at end\n\
1768 -dD Preserve macro definitions in output\n\
1769 -dN As -dD except that only the names are preserved\n\
1770 -dI Include #include directives in the output\n\
1771 -P Do not generate #line directives\n\
1772 -$ Do not allow '$' in identifiers\n\
1773 -remap Remap file names when including files.\n\
1774 --version Display version information\n\
1775 -h or --help Display this information\n\