2 Copyright (C) 1986, 87, 89, 92-99, 2000 Free Software Foundation, Inc.
3 Contributed by Per Bothner, 1994-95.
4 Based on CCCP program by Paul Rubin, June 1986
5 Adapted to ANSI C, Richard Stallman, Jan 1987
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32 /* Predefined symbols, built-in macros, and the default include path. */
34 #ifndef GET_ENV_PATH_LIST
35 #define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
38 #ifndef STANDARD_INCLUDE_DIR
39 #define STANDARD_INCLUDE_DIR "/usr/include"
42 /* We let tm.h override the types used here, to handle trivial differences
43 such as the choice of unsigned int or long unsigned int for size_t.
44 When machines start needing nontrivial differences in the size type,
45 it would be best to do something here to figure out automatically
46 from other information what type to use. */
48 /* The string value for __SIZE_TYPE__. */
51 #define SIZE_TYPE "long unsigned int"
54 /* The string value for __PTRDIFF_TYPE__. */
57 #define PTRDIFF_TYPE "long int"
60 /* The string value for __WCHAR_TYPE__. */
63 #define WCHAR_TYPE "int"
65 #define CPP_WCHAR_TYPE(PFILE) \
66 (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE)
68 /* The string value for __USER_LABEL_PREFIX__ */
70 #ifndef USER_LABEL_PREFIX
71 #define USER_LABEL_PREFIX ""
74 /* The string value for __REGISTER_PREFIX__ */
76 #ifndef REGISTER_PREFIX
77 #define REGISTER_PREFIX ""
80 /* Suffix for object files, and known input-file extensions. */
81 static const char * const known_suffixes
[] =
83 ".c", ".C", ".s", ".S", ".m",
84 ".cc", ".cxx", ".cpp", ".cp", ".c++",
90 # define OBJECT_SUFFIX ".obj"
92 # define OBJECT_SUFFIX ".o"
97 /* This is the default list of directories to search for include files.
98 It may be overridden by the various -I and -ixxx options.
100 #include "file" looks in the same directory as the current file,
102 #include <file> just looks in this list.
104 All these directories are treated as `system' include directories
105 (they are not subject to pedantic warnings in some cases). */
107 static struct default_include
109 const char *fname
; /* The name of the directory. */
110 const char *component
; /* The component containing the directory
111 (see update_path in prefix.c) */
112 int cplusplus
; /* Only look here if we're compiling C++. */
113 int cxx_aware
; /* Includes in this directory don't need to
114 be wrapped in extern "C" when compiling
115 C++. This is not used anymore. */
117 include_defaults_array
[]
118 #ifdef INCLUDE_DEFAULTS
122 /* Pick up GNU C++ specific include files. */
123 { GPLUSPLUS_INCLUDE_DIR
, "G++", 1, 1 },
125 /* This is the dir for fixincludes. Put it just before
126 the files that we fix. */
127 { GCC_INCLUDE_DIR
, "GCC", 0, 0 },
128 /* For cross-compilation, this dir name is generated
129 automatically in Makefile.in. */
130 { CROSS_INCLUDE_DIR
, "GCC", 0, 0 },
131 #ifdef TOOL_INCLUDE_DIR
132 /* This is another place that the target system's headers might be. */
133 { TOOL_INCLUDE_DIR
, "BINUTILS", 0, 1 },
135 #else /* not CROSS_COMPILE */
136 #ifdef LOCAL_INCLUDE_DIR
137 /* This should be /usr/local/include and should come before
138 the fixincludes-fixed header files. */
139 { LOCAL_INCLUDE_DIR
, 0, 0, 1 },
141 #ifdef TOOL_INCLUDE_DIR
142 /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here.
143 Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */
144 { TOOL_INCLUDE_DIR
, "BINUTILS", 0, 1 },
146 /* This is the dir for fixincludes. Put it just before
147 the files that we fix. */
148 { GCC_INCLUDE_DIR
, "GCC", 0, 0 },
149 /* Some systems have an extra dir of include files. */
150 #ifdef SYSTEM_INCLUDE_DIR
151 { SYSTEM_INCLUDE_DIR
, 0, 0, 0 },
153 #ifndef STANDARD_INCLUDE_COMPONENT
154 #define STANDARD_INCLUDE_COMPONENT 0
156 { STANDARD_INCLUDE_DIR
, STANDARD_INCLUDE_COMPONENT
, 0, 0 },
157 #endif /* not CROSS_COMPILE */
160 #endif /* no INCLUDE_DEFAULTS */
162 /* Internal structures and prototypes. */
164 /* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
165 switch. There are four lists: one for -D and -U, one for -A, one
166 for -include, one for -imacros. `undef' is set for -U, clear for
167 -D, ignored for the others.
168 (Future: add an equivalent of -U for -A) */
169 struct pending_option
171 struct pending_option
*next
;
177 #define APPEND(pend, list, elt) \
178 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
179 else (pend)->list##_tail->next = (elt); \
180 (pend)->list##_tail = (elt); \
183 #define APPEND(pend, list, elt) \
184 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
185 else (pend)->list/**/_tail->next = (elt); \
186 (pend)->list/**/_tail = (elt); \
190 static void print_help
PARAMS ((void));
191 static void path_include
PARAMS ((cpp_reader
*,
192 struct cpp_pending
*,
194 static void initialize_builtins
PARAMS ((cpp_reader
*));
195 static void append_include_chain
PARAMS ((cpp_reader
*,
196 struct cpp_pending
*,
198 static char *base_name
PARAMS ((const char *));
199 static void dump_special_to_buffer
PARAMS ((cpp_reader
*, const char *));
200 static void initialize_dependency_output
PARAMS ((cpp_reader
*));
201 static void new_pending_define
PARAMS ((struct cpp_options
*,
204 /* Last argument to append_include_chain: chain to use */
205 enum { QUOTE
= 0, BRACKET
, SYSTEM
, AFTER
};
207 /* If gcc is in use (stage2/stage3) we can make this table initialized data. */
209 #define CAT(a, b) a##b
211 #define CAT(a, b) a/**/b
214 #if (GCC_VERSION >= 2007)
215 #define TABLE(id) static inline void CAT(init_, id) PARAMS ((void)) {} \
216 unsigned char id[256] = {
217 #define s(p, v) [p] = v,
220 #define TABLE(id) unsigned char id[256] = { 0 }; \
221 static void CAT(init_,id) PARAMS ((void)) { \
222 unsigned char *x = id;
223 #define s(p, v) x[p] = v;
227 #define A(x) s(x, ISidnum|ISidstart)
228 #define N(x) s(x, ISidnum|ISnumstart)
229 #define H(x) s(x, IShspace|ISspace)
230 #define S(x) s(x, ISspace)
235 A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
236 A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
237 A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
239 A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
240 A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
241 A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
243 N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
245 H(' ') H('\t') H('\v') H('\f')
259 /* Given a colon-separated list of file names PATH,
260 add all the names to the search path for include files. */
263 path_include (pfile
, pend
, list
, path
)
265 struct cpp_pending
*pend
;
275 /* Find the end of this name. */
277 while (*q
!= 0 && *q
!= PATH_SEPARATOR
) q
++;
280 /* An empty name in the path stands for the current directory. */
281 name
= (char *) xmalloc (2);
287 /* Otherwise use the directory that is named. */
288 name
= (char *) xmalloc (q
- p
+ 1);
289 memcpy (name
, p
, q
- p
);
293 append_include_chain (pfile
, pend
, name
, path
);
295 /* Advance past this name. */
303 /* Find the base name of a (partial) pathname FNAME.
304 Returns a pointer into the string passed in.
305 Accepts Unix (/-separated) paths on all systems,
306 DOS and VMS paths on those systems. */
311 char *s
= (char *)fname
;
313 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
314 if (ISALPHA (s
[0]) && s
[1] == ':') s
+= 2;
315 if ((p
= rindex (s
, '\\'))) s
= p
+ 1;
317 if ((p
= rindex (s
, ':'))) s
= p
+ 1; /* Skip device. */
318 if ((p
= rindex (s
, ']'))) s
= p
+ 1; /* Skip directory. */
319 if ((p
= rindex (s
, '>'))) s
= p
+ 1; /* Skip alternate (int'n'l) dir. */
321 if ((p
= rindex (s
, '/'))) s
= p
+ 1;
326 /* Append DIR to include path PATH. DIR must be permanently allocated
329 append_include_chain (pfile
, pend
, dir
, path
)
331 struct cpp_pending
*pend
;
335 struct file_name_list
*new;
339 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
;
365 new->sysp
= (path
== SYSTEM
);
366 new->name_map
= NULL
;
372 case QUOTE
: APPEND (pend
, quote
, new); break;
373 case BRACKET
: APPEND (pend
, brack
, new); break;
374 case SYSTEM
: APPEND (pend
, systm
, new); break;
375 case AFTER
: APPEND (pend
, after
, new); break;
380 /* Write out a #define command for the special named MACRO_NAME
381 to PFILE's token_buffer. */
384 dump_special_to_buffer (pfile
, macro_name
)
386 const char *macro_name
;
388 static char define_directive
[] = "#define ";
389 int macro_name_length
= strlen (macro_name
);
390 output_line_command (pfile
, same_file
);
391 CPP_RESERVE (pfile
, sizeof(define_directive
) + macro_name_length
);
392 CPP_PUTS_Q (pfile
, define_directive
, sizeof(define_directive
)-1);
393 CPP_PUTS_Q (pfile
, macro_name
, macro_name_length
);
394 CPP_PUTC_Q (pfile
, ' ');
395 cpp_expand_to_buffer (pfile
, macro_name
, macro_name_length
);
396 CPP_PUTC (pfile
, '\n');
399 /* Initialize a cpp_options structure. */
401 cpp_options_init (opts
)
404 bzero ((char *) opts
, sizeof (struct cpp_options
));
406 opts
->dollars_in_ident
= 1;
407 opts
->cplusplus_comments
= 1;
408 opts
->warn_import
= 1;
409 opts
->discard_comments
= 1;
412 (struct cpp_pending
*) xcalloc (1, sizeof (struct cpp_pending
));
415 /* Initialize a cpp_reader structure. */
417 cpp_reader_init (pfile
)
420 bzero ((char *) pfile
, sizeof (cpp_reader
));
422 pfile
->token_buffer_size
= 200;
423 pfile
->token_buffer
= (U_CHAR
*) xmalloc (pfile
->token_buffer_size
);
424 CPP_SET_WRITTEN (pfile
, 0);
426 pfile
->hashtab
= (HASHNODE
**) xcalloc (HASHSIZE
, sizeof (HASHNODE
*));
429 /* Free resources used by PFILE.
430 This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology). */
436 while (CPP_BUFFER (pfile
) != CPP_NULL_BUFFER (pfile
))
437 cpp_pop_buffer (pfile
);
439 if (pfile
->token_buffer
)
441 free (pfile
->token_buffer
);
442 pfile
->token_buffer
= NULL
;
445 if (pfile
->deps_buffer
)
447 free (pfile
->deps_buffer
);
448 pfile
->deps_buffer
= NULL
;
449 pfile
->deps_allocated_size
= 0;
452 if (pfile
->input_buffer
)
454 free (pfile
->input_buffer
);
455 free (pfile
->input_speccase
);
456 pfile
->input_buffer
= pfile
->input_speccase
= NULL
;
457 pfile
->input_buffer_len
= 0;
460 while (pfile
->if_stack
)
462 IF_STACK_FRAME
*temp
= pfile
->if_stack
;
463 pfile
->if_stack
= temp
->next
;
467 for (i
= ALL_INCLUDE_HASHSIZE
; --i
>= 0; )
469 struct include_hash
*imp
= pfile
->all_include_files
[i
];
472 struct include_hash
*next
= imp
->next
;
474 /* This gets freed elsewhere - I think. */
480 pfile
->all_include_files
[i
] = 0;
483 for (i
= HASHSIZE
; --i
>= 0;)
485 while (pfile
->hashtab
[i
])
486 delete_macro (pfile
->hashtab
[i
]);
488 free (pfile
->hashtab
);
492 /* This structure defines one built-in macro. A node of type TYPE will
493 be entered in the macro hash table under the name NAME, with value
494 VALUE (if any). FLAGS tweaks the behavior a little:
495 DUMP write debug info for this macro
496 STDC define only if not -traditional
497 ULP value is the global user_label_prefix (which can't be
498 put directly into the table).
506 unsigned short flags
;
512 static const struct builtin builtin_array
[] =
514 { "__TIME__", 0, T_TIME
, DUMP
},
515 { "__DATE__", 0, T_DATE
, DUMP
},
516 { "__FILE__", 0, T_FILE
, 0 },
517 { "__BASE_FILE__", 0, T_BASE_FILE
, DUMP
},
518 { "__LINE__", 0, T_SPECLINE
, 0 },
519 { "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL
, 0 },
520 { "__VERSION__", 0, T_VERSION
, DUMP
},
521 { "__STDC__", 0, T_STDC
, DUMP
|STDC
},
523 { "__USER_LABEL_PREFIX__", 0, T_CONST
, ULP
},
524 { "__REGISTER_PREFIX__", REGISTER_PREFIX
, T_CONST
, 0 },
525 { "__HAVE_BUILTIN_SETJMP__", "1", T_CONST
, 0 },
526 #ifndef NO_BUILTIN_SIZE_TYPE
527 { "__SIZE_TYPE__", SIZE_TYPE
, T_CONST
, DUMP
},
529 #ifndef NO_BUILTIN_PTRDIFF_TYPE
530 { "__PTRDIFF_TYPE__", PTRDIFF_TYPE
, T_CONST
, DUMP
},
532 { "__WCHAR_TYPE__", WCHAR_TYPE
, T_CONST
, DUMP
},
536 /* Subroutine of cpp_start_read; reads the builtins table above and
537 enters the macros into the hash table. */
540 initialize_builtins (pfile
)
544 const struct builtin
*b
;
546 for(b
= builtin_array
; b
->name
; b
++)
548 if ((b
->flags
& STDC
) && CPP_TRADITIONAL (pfile
))
551 val
= (b
->flags
& ULP
) ? user_label_prefix
: b
->value
;
552 len
= strlen (b
->name
);
554 cpp_install (pfile
, b
->name
, len
, b
->type
, val
);
555 if ((b
->flags
& DUMP
) && CPP_OPTIONS (pfile
)->debug_output
)
556 dump_special_to_buffer (pfile
, b
->name
);
564 /* Another subroutine of cpp_start_read. This one sets up to do
565 dependency-file output. */
567 initialize_dependency_output (pfile
)
570 cpp_options
*opts
= CPP_OPTIONS (pfile
);
571 char *spec
, *s
, *output_file
;
573 /* Either of two environment variables can specify output of deps.
574 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
575 where OUTPUT_FILE is the file to write deps info to
576 and DEPS_TARGET is the target to mention in the deps. */
578 if (opts
->print_deps
== 0)
580 spec
= getenv ("DEPENDENCIES_OUTPUT");
582 opts
->print_deps
= 1;
585 spec
= getenv ("SUNPRO_DEPENDENCIES");
587 opts
->print_deps
= 2;
592 /* Find the space before the DEPS_TARGET, if there is one. */
593 s
= strchr (spec
, ' ');
596 opts
->deps_target
= s
+ 1;
597 output_file
= (char *) xmalloc (s
- spec
+ 1);
598 memcpy (output_file
, spec
, s
- spec
);
599 output_file
[s
- spec
] = 0;
603 opts
->deps_target
= 0;
607 opts
->deps_file
= output_file
;
608 opts
->print_deps_append
= 1;
611 /* Print the expected object file name as the target of this Make-rule. */
612 pfile
->deps_allocated_size
= 200;
613 pfile
->deps_buffer
= (char *) xmalloc (pfile
->deps_allocated_size
);
614 pfile
->deps_buffer
[0] = 0;
615 pfile
->deps_size
= 0;
616 pfile
->deps_column
= 0;
618 if (opts
->deps_target
)
619 deps_output (pfile
, opts
->deps_target
, ':');
620 else if (*opts
->in_fname
== 0)
621 deps_output (pfile
, "-", ':');
627 /* Discard all directory prefixes from filename. */
628 q
= base_name (opts
->in_fname
);
630 /* Copy remainder to mungable area. */
632 p
= (char *) alloca (len
+ 8);
635 /* Output P, but remove known suffixes. */
637 /* Point to the filename suffix. */
638 r
= strrchr (p
, '.');
640 /* Compare against the known suffixes. */
641 for (x
= 0; known_suffixes
[x
]; x
++)
642 if (strncmp (known_suffixes
[x
], r
, q
- r
) == 0)
644 /* Make q point to the bit we're going to overwrite
645 with an object suffix. */
650 /* Supply our own suffix. */
651 strcpy (q
, OBJECT_SUFFIX
);
653 deps_output (pfile
, p
, ':');
654 deps_output (pfile
, opts
->in_fname
, ' ');
658 /* This is called after options have been processed.
659 * Check options for consistency, and setup for processing input
660 * from the file named FNAME. (Use standard input if FNAME==NULL.)
661 * Return 1 on success, 0 on failure.
665 cpp_start_read (pfile
, fname
)
669 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
670 struct pending_option
*p
, *q
;
673 struct include_hash
*ih_fake
;
675 /* -MG doesn't select the form of output and must be specified with one of
676 -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
677 inhibit compilation. */
678 if (opts
->print_deps_missing_files
679 && (opts
->print_deps
== 0 || !opts
->no_output
))
681 cpp_fatal (pfile
, "-MG must be specified with one of -M or -MM");
685 /* Chill should not be used with -trigraphs. */
686 if (opts
->chill
&& opts
->trigraphs
)
688 cpp_warning (pfile
, "-lang-chill and -trigraphs are mutually exclusive");
692 /* Set this if it hasn't been set already. */
693 if (user_label_prefix
== NULL
)
694 user_label_prefix
= USER_LABEL_PREFIX
;
696 /* Now that we know dollars_in_ident, we can initialize the syntax
699 /* XXX Get rid of code that depends on this, then IStable can
701 if (opts
->dollars_in_ident
)
702 IStable
['$'] = ISidstart
|ISidnum
;
704 /* Do partial setup of input buffer for the sake of generating
705 early #line directives (when -g is in effect). */
706 fp
= cpp_push_buffer (pfile
, NULL
, 0);
709 if (opts
->in_fname
== NULL
|| *opts
->in_fname
== 0)
711 opts
->in_fname
= fname
;
712 if (opts
->in_fname
== NULL
)
715 fp
->nominal_fname
= fp
->fname
= opts
->in_fname
;
718 /* Install __LINE__, etc. Must follow initialize_char_syntax
719 and option processing. */
720 initialize_builtins (pfile
);
722 /* Do -U's, -D's and -A's in the order they were seen. */
723 p
= opts
->pending
->define_head
;
726 if (opts
->debug_output
)
727 output_line_command (pfile
, same_file
);
729 cpp_undef (pfile
, p
->arg
);
731 cpp_define (pfile
, p
->arg
);
738 p
= opts
->pending
->assert_head
;
741 if (opts
->debug_output
)
742 output_line_command (pfile
, same_file
);
744 cpp_unassert (pfile
, p
->arg
);
746 cpp_assert (pfile
, p
->arg
);
753 opts
->done_initializing
= 1;
755 /* Several environment variables may add to the include search path.
756 CPATH specifies an additional list of directories to be searched
757 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
758 etc. specify an additional list of directories to be searched as
759 if specified with -isystem, for the language indicated.
761 These variables are ignored if -nostdinc is on. */
762 if (! opts
->no_standard_includes
)
765 GET_ENV_PATH_LIST (path
, "CPATH");
766 if (path
!= 0 && *path
!= 0)
767 path_include (pfile
, opts
->pending
, path
, BRACKET
);
769 switch ((opts
->objc
<< 1) + opts
->cplusplus
)
772 GET_ENV_PATH_LIST (path
, "C_INCLUDE_PATH");
775 GET_ENV_PATH_LIST (path
, "CPLUS_INCLUDE_PATH");
778 GET_ENV_PATH_LIST (path
, "OBJC_INCLUDE_PATH");
781 GET_ENV_PATH_LIST (path
, "OBJCPLUS_INCLUDE_PATH");
784 if (path
!= 0 && *path
!= 0)
785 path_include (pfile
, opts
->pending
, path
, SYSTEM
);
788 /* Unless -nostdinc, add the compiled-in include path to the list,
789 translating prefixes. */
790 if (!opts
->no_standard_includes
)
792 struct default_include
*p
= include_defaults_array
;
793 char *specd_prefix
= opts
->include_prefix
;
795 /* Search "translated" versions of GNU directories.
796 These have /usr/local/lib/gcc... replaced by specd_prefix. */
797 if (specd_prefix
!= 0)
799 char *default_prefix
= alloca (sizeof GCC_INCLUDE_DIR
- 7);
800 /* Remove the `include' from /usr/local/lib/gcc.../include.
801 GCC_INCLUDE_DIR will always end in /include. */
802 int default_len
= sizeof GCC_INCLUDE_DIR
- 8;
803 int specd_len
= strlen (specd_prefix
);
805 memcpy (default_prefix
, GCC_INCLUDE_DIR
, default_len
);
806 default_prefix
[default_len
] = '\0';
808 for (p
= include_defaults_array
; p
->fname
; p
++)
810 /* Some standard dirs are only for C++. */
813 && !opts
->no_standard_cplusplus_includes
))
815 /* Does this dir start with the prefix? */
816 if (!strncmp (p
->fname
, default_prefix
, default_len
))
818 /* Yes; change prefix and add to search list. */
819 int flen
= strlen (p
->fname
);
820 int this_len
= specd_len
+ flen
- default_len
;
821 char *str
= (char *) xmalloc (this_len
+ 1);
822 memcpy (str
, specd_prefix
, specd_len
);
823 memcpy (str
+ specd_len
,
824 p
->fname
+ default_len
,
825 flen
- default_len
+ 1);
827 append_include_chain (pfile
, opts
->pending
,
834 /* Search ordinary names for GNU include directories. */
835 for (p
= include_defaults_array
; p
->fname
; p
++)
837 /* Some standard dirs are only for C++. */
840 && !opts
->no_standard_cplusplus_includes
))
842 /* XXX Potential memory leak! */
843 char *str
= xstrdup (update_path (p
->fname
, p
->component
));
844 append_include_chain (pfile
, opts
->pending
, str
, SYSTEM
);
849 merge_include_chains (opts
);
851 /* With -v, print the list of dirs to search. */
854 struct file_name_list
*p
;
855 fprintf (stderr
, _("#include \"...\" search starts here:\n"));
856 for (p
= opts
->quote_include
; p
; p
= p
->next
)
858 if (p
== opts
->bracket_include
)
859 fprintf (stderr
, _("#include <...> search starts here:\n"));
860 fprintf (stderr
, " %s\n", p
->name
);
862 fprintf (stderr
, _("End of search list.\n"));
865 /* Don't bother trying to do macro expansion if we've already done
867 if (opts
->preprocessed
)
868 pfile
->no_macro_expand
++;
870 /* Open the main input file.
871 We do this in nonblocking mode so we don't get stuck here if
872 someone clever has asked cpp to process /dev/rmt0;
873 finclude() will check that we have a real file to work with. */
874 if (fname
== NULL
|| *fname
== 0)
879 else if ((f
= open (fname
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666)) < 0)
881 cpp_notice_from_errno (pfile
, fname
);
885 initialize_dependency_output (pfile
);
887 /* Must call finclude() on the main input before processing
888 -include switches; otherwise the -included text winds up
889 after the main input. */
890 ih_fake
= (struct include_hash
*) xmalloc (sizeof (struct include_hash
));
892 ih_fake
->next_this_file
= 0;
893 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
894 ih_fake
->name
= fname
;
895 ih_fake
->control_macro
= 0;
896 ih_fake
->buf
= (char *)-1;
898 if (!finclude (pfile
, f
, ih_fake
))
900 if (opts
->preprocessed
)
901 /* If we've already processed this code, we want to trust the #line
902 directives in the input. But we still need to update our line
903 counter accordingly. */
904 pfile
->lineno
= CPP_BUFFER (pfile
)->lineno
;
906 output_line_command (pfile
, same_file
);
907 pfile
->only_seen_white
= 2;
909 /* The -imacros files can be scanned now, but the -include files
910 have to be pushed onto the include stack and processed later,
911 in the main loop calling cpp_get_token. */
913 pfile
->no_record_file
++;
915 p
= opts
->pending
->imacros_head
;
918 int fd
= open (p
->arg
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666);
921 cpp_notice_from_errno (pfile
, p
->arg
);
924 if (!cpp_push_buffer (pfile
, NULL
, 0))
927 ih_fake
= (struct include_hash
*)
928 xmalloc (sizeof (struct include_hash
));
930 ih_fake
->next_this_file
= 0;
931 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
932 ih_fake
->name
= p
->arg
;
933 ih_fake
->control_macro
= 0;
934 ih_fake
->buf
= (char *)-1;
936 if (finclude (pfile
, fd
, ih_fake
))
938 if (CPP_PRINT_DEPS (pfile
))
939 deps_output (pfile
, ih_fake
->name
, ' ');
941 cpp_scan_buffer (pfile
);
944 cpp_pop_buffer (pfile
);
954 p
= opts
->pending
->include_head
;
957 int fd
= open (p
->arg
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666);
960 cpp_notice_from_errno (pfile
, p
->arg
);
963 if (!cpp_push_buffer (pfile
, NULL
, 0))
966 ih_fake
= (struct include_hash
*)
967 xmalloc (sizeof (struct include_hash
));
969 ih_fake
->next_this_file
= 0;
970 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
971 ih_fake
->name
= p
->arg
;
972 ih_fake
->control_macro
= 0;
973 ih_fake
->buf
= (char *)-1;
975 if (finclude (pfile
, fd
, ih_fake
))
977 if (CPP_PRINT_DEPS (pfile
))
978 deps_output (pfile
, ih_fake
->name
, ' ');
980 output_line_command (pfile
, enter_file
);
983 cpp_pop_buffer (pfile
);
988 pfile
->no_record_file
--;
990 free (opts
->pending
);
991 opts
->pending
= NULL
;
996 /* This is called at the end of preprocessing. It pops the
997 last buffer and writes dependency output. It should also
998 clear macro definitions, such that you could call cpp_start_read
999 with a new filename to restart processing. */
1004 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
1006 if (CPP_PREV_BUFFER (CPP_BUFFER (pfile
)) != CPP_NULL_BUFFER (pfile
))
1007 cpp_ice (pfile
, "buffers still stacked in cpp_finish");
1008 cpp_pop_buffer (pfile
);
1010 if (opts
->print_deps
)
1012 /* Stream on which to print the dependency information. */
1013 FILE *deps_stream
= 0;
1015 /* Don't actually write the deps file if compilation has failed. */
1016 if (pfile
->errors
== 0)
1018 const char *deps_mode
= opts
->print_deps_append
? "a" : "w";
1019 if (opts
->deps_file
== 0)
1020 deps_stream
= stdout
;
1021 else if ((deps_stream
= fopen (opts
->deps_file
, deps_mode
)) == 0)
1022 cpp_notice_from_errno (pfile
, opts
->deps_file
);
1026 fputs (pfile
->deps_buffer
, deps_stream
);
1027 putc ('\n', deps_stream
);
1028 if (opts
->deps_file
)
1030 if (ferror (deps_stream
) || fclose (deps_stream
) != 0)
1031 cpp_fatal (pfile
, "I/O error on output");
1037 if (opts
->dump_macros
== dump_only
)
1041 for (i
= HASHSIZE
; --i
>= 0;)
1043 for (h
= pfile
->hashtab
[i
]; h
; h
= h
->next
)
1044 if (h
->type
== T_MACRO
)
1046 dump_definition (pfile
, h
->name
, h
->length
, h
->value
.defn
);
1047 CPP_PUTC (pfile
, '\n');
1054 new_pending_define (opts
, text
)
1055 struct cpp_options
*opts
;
1058 struct pending_option
*o
= (struct pending_option
*)
1059 xmalloc (sizeof (struct pending_option
));
1061 o
->arg
= (char *) text
;
1064 APPEND (opts
->pending
, define
, o
);
1067 /* Handle one command-line option in (argc, argv).
1068 Can be called multiple times, to handle multiple sets of options.
1069 Returns number of strings consumed. */
1072 cpp_handle_option (pfile
, argc
, argv
)
1077 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
1080 if (argv
[i
][0] != '-')
1082 if (opts
->out_fname
!= NULL
)
1085 cpp_fatal (pfile
, "Too many arguments");
1087 else if (opts
->in_fname
!= NULL
)
1088 opts
->out_fname
= argv
[i
];
1090 opts
->in_fname
= argv
[i
];
1096 if (!strcmp (argv
[i
], "-fleading-underscore"))
1097 user_label_prefix
= "_";
1098 else if (!strcmp (argv
[i
], "-fno-leading-underscore"))
1099 user_label_prefix
= "";
1100 else if (!strcmp (argv
[i
], "-fpreprocessed"))
1101 opts
->preprocessed
= 1;
1102 else if (!strcmp (argv
[i
], "-fno-preprocessed"))
1103 opts
->preprocessed
= 0;
1110 case 'I': /* Add directory to path for includes. */
1111 if (!strcmp (argv
[i
] + 2, "-"))
1114 Use the preceding -I directories for #include "..."
1115 but not #include <...>.
1116 Don't search the directory of the present file
1117 for #include "...". (Note that -I. -I- is not the same as
1118 the default setup; -I. uses the compiler's working dir.) */
1119 if (! opts
->ignore_srcdir
)
1121 opts
->ignore_srcdir
= 1;
1122 opts
->pending
->quote_head
= opts
->pending
->brack_head
;
1123 opts
->pending
->quote_tail
= opts
->pending
->brack_tail
;
1124 opts
->pending
->brack_head
= 0;
1125 opts
->pending
->brack_tail
= 0;
1129 cpp_fatal (pfile
, "-I- specified twice");
1136 if (argv
[i
][2] != 0)
1137 fname
= argv
[i
] + 2;
1138 else if (i
+ 1 == argc
)
1139 goto missing_dirname
;
1142 append_include_chain (pfile
, opts
->pending
,
1143 xstrdup (fname
), BRACKET
);
1148 /* Add directory to beginning of system include path, as a system
1149 include directory. */
1150 if (!strcmp (argv
[i
], "-isystem"))
1153 goto missing_filename
;
1154 append_include_chain (pfile
, opts
->pending
,
1155 xstrdup (argv
[++i
]), SYSTEM
);
1157 else if (!strcmp (argv
[i
], "-include"))
1160 goto missing_filename
;
1163 struct pending_option
*o
= (struct pending_option
*)
1164 xmalloc (sizeof (struct pending_option
));
1167 /* This list has to be built in reverse order so that
1168 when cpp_start_read pushes all the -include files onto
1169 the buffer stack, they will be scanned in forward order. */
1170 o
->next
= opts
->pending
->include_head
;
1171 opts
->pending
->include_head
= o
;
1174 else if (!strcmp (argv
[i
], "-imacros"))
1177 goto missing_filename
;
1180 struct pending_option
*o
= (struct pending_option
*)
1181 xmalloc (sizeof (struct pending_option
));
1185 APPEND (opts
->pending
, imacros
, o
);
1188 /* Add directory to end of path for includes,
1189 with the default prefix at the front of its name. */
1190 else if (!strcmp (argv
[i
], "-iwithprefix"))
1195 goto missing_dirname
;
1197 len
= strlen (argv
[i
]);
1199 if (opts
->include_prefix
!= 0)
1201 fname
= xmalloc (opts
->include_prefix_len
+ len
+ 1);
1202 memcpy (fname
, opts
->include_prefix
, opts
->include_prefix_len
);
1203 memcpy (fname
+ opts
->include_prefix_len
, argv
[i
], len
+ 1);
1207 fname
= xmalloc (sizeof GCC_INCLUDE_DIR
- 8 + len
);
1208 memcpy (fname
, GCC_INCLUDE_DIR
, sizeof GCC_INCLUDE_DIR
- 9);
1209 memcpy (fname
+ sizeof GCC_INCLUDE_DIR
- 9, argv
[i
], len
+ 1);
1212 append_include_chain (pfile
, opts
->pending
, fname
, SYSTEM
);
1214 /* Add directory to main path for includes,
1215 with the default prefix at the front of its name. */
1216 else if (!strcmp (argv
[i
], "-iwithprefixbefore"))
1221 goto missing_dirname
;
1223 len
= strlen (argv
[i
]);
1225 if (opts
->include_prefix
!= 0)
1227 fname
= xmalloc (opts
->include_prefix_len
+ len
+ 1);
1228 memcpy (fname
, opts
->include_prefix
, opts
->include_prefix_len
);
1229 memcpy (fname
+ opts
->include_prefix_len
, argv
[i
], len
+ 1);
1233 fname
= xmalloc (sizeof GCC_INCLUDE_DIR
- 8 + len
);
1234 memcpy (fname
, GCC_INCLUDE_DIR
, sizeof GCC_INCLUDE_DIR
- 9);
1235 memcpy (fname
+ sizeof GCC_INCLUDE_DIR
- 9, argv
[i
], len
+ 1);
1238 append_include_chain (pfile
, opts
->pending
, fname
, BRACKET
);
1240 /* Add directory to end of path for includes. */
1241 else if (!strcmp (argv
[i
], "-idirafter"))
1244 goto missing_dirname
;
1245 append_include_chain (pfile
, opts
->pending
,
1246 xstrdup (argv
[++i
]), AFTER
);
1248 else if (!strcmp (argv
[i
], "-iprefix"))
1251 goto missing_filename
;
1254 opts
->include_prefix
= argv
[++i
];
1255 opts
->include_prefix_len
= strlen (argv
[i
]);
1258 else if (!strcmp (argv
[i
], "-ifoutput"))
1259 opts
->output_conditionals
= 1;
1264 if (opts
->out_fname
!= NULL
)
1266 cpp_fatal (pfile
, "Output filename specified twice");
1270 goto missing_filename
;
1271 opts
->out_fname
= argv
[++i
];
1272 if (!strcmp (opts
->out_fname
, "-"))
1273 opts
->out_fname
= "";
1277 if (!strcmp (argv
[i
], "-pedantic"))
1278 CPP_PEDANTIC (pfile
) = 1;
1279 else if (!strcmp (argv
[i
], "-pedantic-errors"))
1281 CPP_PEDANTIC (pfile
) = 1;
1282 opts
->pedantic_errors
= 1;
1287 if (!strcmp (argv
[i
], "-traditional"))
1289 opts
->traditional
= 1;
1290 opts
->cplusplus_comments
= 0;
1291 opts
->trigraphs
= 0;
1292 opts
->warn_trigraphs
= 0;
1294 else if (!strcmp (argv
[i
], "-trigraphs"))
1295 opts
->trigraphs
= 1;
1299 if (! strcmp (argv
[i
], "-lang-c"))
1300 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1301 opts
->c99
= 1, opts
->objc
= 0;
1302 if (! strcmp (argv
[i
], "-lang-c89"))
1304 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1305 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1306 opts
->trigraphs
= 1;
1307 new_pending_define (opts
, "__STRICT_ANSI__");
1309 if (! strcmp (argv
[i
], "-lang-c++"))
1310 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1311 opts
->c99
= 0, opts
->objc
= 0;
1312 if (! strcmp (argv
[i
], "-lang-objc"))
1313 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1314 opts
->c99
= 0, opts
->objc
= 1;
1315 if (! strcmp (argv
[i
], "-lang-objc++"))
1316 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1317 opts
->c99
= 0, opts
->objc
= 1;
1318 if (! strcmp (argv
[i
], "-lang-asm"))
1320 if (! strcmp (argv
[i
], "-lang-fortran"))
1321 opts
->lang_fortran
= 1, opts
->cplusplus_comments
= 0;
1322 if (! strcmp (argv
[i
], "-lang-chill"))
1323 opts
->objc
= 0, opts
->cplusplus
= 0, opts
->chill
= 1,
1324 opts
->traditional
= 1;
1328 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1;
1332 if (!strcmp (argv
[i
], "-std=gnu89"))
1334 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1335 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1337 else if (!strcmp (argv
[i
], "-std=gnu9x")
1338 || !strcmp (argv
[i
], "-std=gnu99"))
1340 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1341 opts
->c89
= 0, opts
->c99
= 1, opts
->objc
= 0;
1342 new_pending_define (opts
, "__STDC_VERSION__=199901L");
1344 else if (!strcmp (argv
[i
], "-std=iso9899:1990")
1345 || !strcmp (argv
[i
], "-std=c89"))
1347 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1348 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1349 opts
->trigraphs
= 1;
1350 new_pending_define (opts
, "__STRICT_ANSI__");
1352 else if (!strcmp (argv
[i
], "-std=iso9899:199409"))
1354 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1355 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1356 opts
->trigraphs
= 1;
1357 new_pending_define (opts
, "__STRICT_ANSI__");
1358 new_pending_define (opts
, "__STDC_VERSION__=199409L");
1360 else if (!strcmp (argv
[i
], "-std=iso9899:199x")
1361 || !strcmp (argv
[i
], "-std=iso9899:1999")
1362 || !strcmp (argv
[i
], "-std=c9x")
1363 || !strcmp (argv
[i
], "-std=c99"))
1365 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1366 opts
->c89
= 0, opts
->c99
= 1, opts
->objc
= 0;
1367 opts
->trigraphs
= 1;
1368 new_pending_define (opts
, "__STRICT_ANSI__");
1369 new_pending_define (opts
, "__STDC_VERSION__=199901L");
1374 opts
->inhibit_warnings
= 1;
1378 if (!strcmp (argv
[i
], "-Wtrigraphs"))
1379 opts
->warn_trigraphs
= 1;
1380 else if (!strcmp (argv
[i
], "-Wno-trigraphs"))
1381 opts
->warn_trigraphs
= 0;
1382 else if (!strcmp (argv
[i
], "-Wcomment"))
1383 opts
->warn_comments
= 1;
1384 else if (!strcmp (argv
[i
], "-Wno-comment"))
1385 opts
->warn_comments
= 0;
1386 else if (!strcmp (argv
[i
], "-Wcomments"))
1387 opts
->warn_comments
= 1;
1388 else if (!strcmp (argv
[i
], "-Wno-comments"))
1389 opts
->warn_comments
= 0;
1390 else if (!strcmp (argv
[i
], "-Wtraditional"))
1391 opts
->warn_stringify
= 1;
1392 else if (!strcmp (argv
[i
], "-Wno-traditional"))
1393 opts
->warn_stringify
= 0;
1394 else if (!strcmp (argv
[i
], "-Wundef"))
1395 opts
->warn_undef
= 1;
1396 else if (!strcmp (argv
[i
], "-Wno-undef"))
1397 opts
->warn_undef
= 0;
1398 else if (!strcmp (argv
[i
], "-Wimport"))
1399 opts
->warn_import
= 1;
1400 else if (!strcmp (argv
[i
], "-Wno-import"))
1401 opts
->warn_import
= 0;
1402 else if (!strcmp (argv
[i
], "-Werror"))
1403 opts
->warnings_are_errors
= 1;
1404 else if (!strcmp (argv
[i
], "-Wno-error"))
1405 opts
->warnings_are_errors
= 0;
1406 else if (!strcmp (argv
[i
], "-Wall"))
1408 opts
->warn_trigraphs
= 1;
1409 opts
->warn_comments
= 1;
1414 /* The style of the choices here is a bit mixed.
1415 The chosen scheme is a hybrid of keeping all options in one string
1416 and specifying each option in a separate argument:
1417 -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
1418 -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
1419 -M[M][G][D file]. This is awkward to handle in specs, and is not
1421 /* ??? -MG must be specified in addition to one of -M or -MM.
1422 This can be relaxed in the future without breaking anything.
1423 The converse isn't true. */
1425 /* -MG isn't valid with -MD or -MMD. This is checked for later. */
1426 if (!strcmp (argv
[i
], "-MG"))
1428 opts
->print_deps_missing_files
= 1;
1431 if (!strcmp (argv
[i
], "-M"))
1432 opts
->print_deps
= 2;
1433 else if (!strcmp (argv
[i
], "-MM"))
1434 opts
->print_deps
= 1;
1435 else if (!strcmp (argv
[i
], "-MD"))
1436 opts
->print_deps
= 2;
1437 else if (!strcmp (argv
[i
], "-MMD"))
1438 opts
->print_deps
= 1;
1439 /* For -MD and -MMD options, write deps on file named by next arg. */
1440 if (!strcmp (argv
[i
], "-MD") || !strcmp (argv
[i
], "-MMD"))
1443 goto missing_filename
;
1444 opts
->deps_file
= argv
[++i
];
1448 /* For -M and -MM, write deps on standard output
1449 and suppress the usual output. */
1450 opts
->no_output
= 1;
1456 char *p
= argv
[i
] + 2;
1458 while ((c
= *p
++) != 0)
1460 /* Arg to -d specifies what parts of macros to dump */
1464 opts
->dump_macros
= dump_only
;
1465 opts
->no_output
= 1;
1468 opts
->dump_macros
= dump_names
;
1471 opts
->dump_macros
= dump_definitions
;
1474 opts
->dump_includes
= 1;
1482 if (argv
[i
][2] == '3')
1483 opts
->debug_output
= 1;
1487 if (!strcmp (argv
[i
], "--help"))
1489 else if (!strcmp (argv
[i
], "--version"))
1490 fprintf (stderr
, _("GNU CPP version %s (cpplib)\n"), version_string
);
1495 fprintf (stderr
, _("GNU CPP version %s (cpplib)\n"), version_string
);
1496 #ifdef TARGET_VERSION
1499 fputc ('\n', stderr
);
1504 opts
->print_include_names
= 1;
1510 if (argv
[i
][2] != 0)
1512 else if (i
+ 1 == argc
)
1514 cpp_fatal (pfile
, "Macro name missing after -D option");
1519 new_pending_define (opts
, text
);
1527 if (argv
[i
][2] != 0)
1529 else if (i
+ 1 == argc
)
1531 cpp_fatal (pfile
, "Assertion missing after -A option");
1537 if (strcmp (p
, "-"))
1539 struct pending_option
*o
= (struct pending_option
*)
1540 xmalloc (sizeof (struct pending_option
));
1545 APPEND (opts
->pending
, assert, o
);
1549 /* -A- eliminates all predefined macros and assertions.
1550 Let's include also any that were specified earlier
1551 on the command line. That way we can get rid of any
1552 that were passed automatically in from GCC. */
1553 struct pending_option
*o1
, *o2
;
1555 o1
= opts
->pending
->define_head
;
1562 o1
= opts
->pending
->assert_head
;
1569 opts
->pending
->assert_head
= NULL
;
1570 opts
->pending
->assert_tail
= NULL
;
1571 opts
->pending
->define_head
= NULL
;
1572 opts
->pending
->define_tail
= NULL
;
1579 struct pending_option
*o
= (struct pending_option
*)
1580 xmalloc (sizeof (struct pending_option
));
1582 if (argv
[i
][2] != 0)
1583 o
->arg
= argv
[i
] + 2;
1584 else if (i
+ 1 == argc
)
1586 cpp_fatal (pfile
, "Macro name missing after -U option");
1594 APPEND (opts
->pending
, define
, o
);
1599 opts
->discard_comments
= 0;
1602 case 'E': /* -E comes from cc -E; ignore it. */
1606 opts
->no_line_commands
= 1;
1609 case '$': /* Don't include $ in identifiers. */
1610 opts
->dollars_in_ident
= 0;
1614 if (!strcmp (argv
[i
], "-nostdinc"))
1615 /* -nostdinc causes no default include directories.
1616 You must specify all include-file directories with -I. */
1617 opts
->no_standard_includes
= 1;
1618 else if (!strcmp (argv
[i
], "-nostdinc++"))
1619 /* -nostdinc++ causes no default C++-specific include directories. */
1620 opts
->no_standard_cplusplus_includes
= 1;
1624 if (!strcmp (argv
[i
], "-remap"))
1628 case '\0': /* JF handle '-' as file name meaning stdin or stdout */
1629 if (opts
->in_fname
== NULL
)
1630 opts
->in_fname
= "";
1631 else if (opts
->out_fname
== NULL
)
1632 opts
->out_fname
= "";
1634 return i
; /* error */
1644 cpp_fatal (pfile
, "Filename missing after `%s' option", argv
[i
]);
1647 cpp_fatal (pfile
, "Directory name missing after `%s' option", argv
[i
]);
1651 /* Handle command-line options in (argc, argv).
1652 Can be called multiple times, to handle multiple sets of options.
1653 Returns if an unrecognized option is seen.
1654 Returns number of strings consumed. */
1657 cpp_handle_options (pfile
, argc
, argv
)
1663 int strings_processed
;
1664 for (i
= 0; i
< argc
; i
+= strings_processed
)
1666 strings_processed
= cpp_handle_option (pfile
, argc
- i
, argv
+ i
);
1667 if (strings_processed
== 0)
1676 fprintf (stderr
, _("Usage: %s [switches] input output\n"), progname
);
1679 -include <file> Include the contents of <file> before other files\n\
1680 -imacros <file> Accept definition of macros in <file>\n\
1681 -iprefix <path> Specify <path> as a prefix for next two options\n\
1682 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1683 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1684 -isystem <dir> Add <dir> to the start of the system include path\n\
1685 -idirafter <dir> Add <dir> to the end of the system include path\n\
1686 -I <dir> Add <dir> to the end of the main include path\n\
1687 -nostdinc Do not search system include directories\n\
1688 (dirs specified with -isystem will still be used)\n\
1689 -nostdinc++ Do not search system include directories for C++\n\
1690 -o <file> Put output into <file>\n\
1691 -pedantic Issue all warnings demanded by strict ANSI C\n\
1692 -traditional Follow K&R pre-processor behaviour\n\
1693 -trigraphs Support ANSI C trigraphs\n\
1694 -lang-c Assume that the input sources are in C\n\
1695 -lang-c89 Assume that the input sources are in C89\n\
1696 -lang-c++ Assume that the input sources are in C++\n\
1697 -lang-objc Assume that the input sources are in ObjectiveC\n\
1698 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1699 -lang-asm Assume that the input sources are in assembler\n\
1700 -lang-fortran Assume that the input sources are in Fortran\n\
1701 -lang-chill Assume that the input sources are in Chill\n\
1702 -std=<std name> Specify the conformance standard; one of:\n\
1703 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1704 iso9899:199409, iso9899:1999\n\
1705 -+ Allow parsing of C++ style features\n\
1706 -w Inhibit warning messages\n\
1707 -Wtrigraphs Warn if trigraphs are encountered\n\
1708 -Wno-trigraphs Do not warn about trigraphs\n\
1709 -Wcomment{s} Warn if one comment starts inside another\n\
1710 -Wno-comment{s} Do not warn about comments\n\
1711 -Wtraditional Warn if a macro argument is/would be turned into\n\
1712 a string if -traditional is specified\n\
1713 -Wno-traditional Do not warn about stringification\n\
1714 -Wundef Warn if an undefined macro is used by #if\n\
1715 -Wno-undef Do not warn about testing undefined macros\n\
1716 -Wimport Warn about the use of the #import directive\n\
1717 -Wno-import Do not warn about the use of #import\n\
1718 -Werror Treat all warnings as errors\n\
1719 -Wno-error Do not treat warnings as errors\n\
1720 -Wall Enable all preprocessor warnings\n\
1721 -M Generate make dependencies\n\
1722 -MM As -M, but ignore system header files\n\
1723 -MD As -M, but put output in a .d file\n\
1724 -MMD As -MD, but ignore system header files\n\
1725 -MG Treat missing header file as generated files\n\
1726 -g Include #define and #undef directives in the output\n\
1727 -D<macro> Define a <macro> with string '1' as its value\n\
1728 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1729 -A<question> (<answer>) Assert the <answer> to <question>\n\
1730 -U<macro> Undefine <macro> \n\
1731 -v Display the version number\n\
1732 -H Print the name of header files as they are used\n\
1733 -C Do not discard comments\n\
1734 -dM Display a list of macro definitions active at end\n\
1735 -dD Preserve macro definitions in output\n\
1736 -dN As -dD except that only the names are preserved\n\
1737 -dI Include #include directives in the output\n\
1738 -ifoutput Describe skipped code blocks in output \n\
1739 -P Do not generate #line directives\n\
1740 -$ Do not allow '$' in identifiers\n\
1741 -remap Remap file names when including files.\n\
1742 -h or --help Display this information\n\