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. */
31 /* XXX Should be in a header file. */
32 extern char *version_string
;
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 #ifndef STANDARD_INCLUDE_DIR
41 #define STANDARD_INCLUDE_DIR "/usr/include"
44 /* We let tm.h override the types used here, to handle trivial differences
45 such as the choice of unsigned int or long unsigned int for size_t.
46 When machines start needing nontrivial differences in the size type,
47 it would be best to do something here to figure out automatically
48 from other information what type to use. */
50 /* The string value for __SIZE_TYPE__. */
53 #define SIZE_TYPE "long unsigned int"
56 /* The string value for __PTRDIFF_TYPE__. */
59 #define PTRDIFF_TYPE "long int"
62 /* The string value for __WCHAR_TYPE__. */
65 #define WCHAR_TYPE "int"
67 #define CPP_WCHAR_TYPE(PFILE) \
68 (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE)
70 /* The string value for __USER_LABEL_PREFIX__ */
72 #ifndef USER_LABEL_PREFIX
73 #define USER_LABEL_PREFIX ""
76 /* The string value for __REGISTER_PREFIX__ */
78 #ifndef REGISTER_PREFIX
79 #define REGISTER_PREFIX ""
82 /* Suffix for object files, and known input-file extensions. */
83 static const char * const known_suffixes
[] =
85 ".c", ".C", ".s", ".S", ".m",
86 ".cc", ".cxx", ".cpp", ".cp", ".c++",
92 # define OBJECT_SUFFIX ".obj"
94 # define OBJECT_SUFFIX ".o"
99 /* This is the default list of directories to search for include files.
100 It may be overridden by the various -I and -ixxx options.
102 #include "file" looks in the same directory as the current file,
104 #include <file> just looks in this list.
106 All these directories are treated as `system' include directories
107 (they are not subject to pedantic warnings in some cases). */
109 static struct default_include
111 const char *fname
; /* The name of the directory. */
112 const char *component
; /* The component containing the directory
113 (see update_path in prefix.c) */
114 int cplusplus
; /* Only look here if we're compiling C++. */
115 int cxx_aware
; /* Includes in this directory don't need to
116 be wrapped in extern "C" when compiling
117 C++. This is not used anymore. */
119 include_defaults_array
[]
120 #ifdef INCLUDE_DEFAULTS
124 /* Pick up GNU C++ specific include files. */
125 { GPLUSPLUS_INCLUDE_DIR
, "G++", 1, 1 },
127 /* This is the dir for fixincludes. Put it just before
128 the files that we fix. */
129 { GCC_INCLUDE_DIR
, "GCC", 0, 0 },
130 /* For cross-compilation, this dir name is generated
131 automatically in Makefile.in. */
132 { CROSS_INCLUDE_DIR
, "GCC", 0, 0 },
133 #ifdef TOOL_INCLUDE_DIR
134 /* This is another place that the target system's headers might be. */
135 { TOOL_INCLUDE_DIR
, "BINUTILS", 0, 1 },
137 #else /* not CROSS_COMPILE */
138 #ifdef LOCAL_INCLUDE_DIR
139 /* This should be /usr/local/include and should come before
140 the fixincludes-fixed header files. */
141 { LOCAL_INCLUDE_DIR
, 0, 0, 1 },
143 #ifdef TOOL_INCLUDE_DIR
144 /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here.
145 Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */
146 { TOOL_INCLUDE_DIR
, "BINUTILS", 0, 1 },
148 /* This is the dir for fixincludes. Put it just before
149 the files that we fix. */
150 { GCC_INCLUDE_DIR
, "GCC", 0, 0 },
151 /* Some systems have an extra dir of include files. */
152 #ifdef SYSTEM_INCLUDE_DIR
153 { SYSTEM_INCLUDE_DIR
, 0, 0, 0 },
155 #ifndef STANDARD_INCLUDE_COMPONENT
156 #define STANDARD_INCLUDE_COMPONENT 0
158 { STANDARD_INCLUDE_DIR
, STANDARD_INCLUDE_COMPONENT
, 0, 0 },
159 #endif /* not CROSS_COMPILE */
162 #endif /* no INCLUDE_DEFAULTS */
164 /* Internal structures and prototypes. */
166 /* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
167 switch. There are four lists: one for -D and -U, one for -A, one
168 for -include, one for -imacros. `undef' is set for -U, clear for
169 -D, ignored for the others.
170 (Future: add an equivalent of -U for -A) */
171 struct pending_option
173 struct pending_option
*next
;
179 #define APPEND(pend, list, elt) \
180 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
181 else (pend)->list##_tail->next = (elt); \
182 (pend)->list##_tail = (elt); \
185 #define APPEND(pend, list, elt) \
186 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
187 else (pend)->list/**/_tail->next = (elt); \
188 (pend)->list/**/_tail = (elt); \
192 static void print_help
PARAMS ((void));
193 static void path_include
PARAMS ((cpp_reader
*,
194 struct cpp_pending
*,
196 static void initialize_builtins
PARAMS ((cpp_reader
*));
197 static void append_include_chain
PARAMS ((cpp_reader
*,
198 struct cpp_pending
*,
200 static char *base_name
PARAMS ((const char *));
201 static void dump_special_to_buffer
PARAMS ((cpp_reader
*, const char *));
202 static void initialize_dependency_output
PARAMS ((cpp_reader
*));
203 static void new_pending_define
PARAMS ((struct cpp_options
*,
206 /* Last argument to append_include_chain: chain to use */
207 enum { QUOTE
= 0, BRACKET
, SYSTEM
, AFTER
};
209 /* If gcc is in use (stage2/stage3) we can make this table initialized data. */
211 #define CAT(a, b) a##b
213 #define CAT(a, b) a/**/b
216 #if (GCC_VERSION >= 2007)
217 #define TABLE(id) static inline void CAT(init_, id) PARAMS ((void)) {} \
218 unsigned char id[256] = {
219 #define s(p, v) [p] = v,
222 #define TABLE(id) unsigned char id[256] = { 0 }; \
223 static void CAT(init_,id) PARAMS ((void)) { \
224 unsigned char *x = id;
225 #define s(p, v) x[p] = v;
229 #define A(x) s(x, ISidnum|ISidstart)
230 #define N(x) s(x, ISidnum|ISnumstart)
231 #define H(x) s(x, IShspace|ISspace)
232 #define S(x) s(x, ISspace)
237 A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
238 A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
239 A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
241 A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
242 A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
243 A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
245 N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
247 H(' ') H('\t') H('\v') H('\f')
261 /* Given a colon-separated list of file names PATH,
262 add all the names to the search path for include files. */
265 path_include (pfile
, pend
, list
, path
)
267 struct cpp_pending
*pend
;
277 /* Find the end of this name. */
279 while (*q
!= 0 && *q
!= PATH_SEPARATOR
) q
++;
282 /* An empty name in the path stands for the current directory. */
283 name
= (char *) xmalloc (2);
289 /* Otherwise use the directory that is named. */
290 name
= (char *) xmalloc (q
- p
+ 1);
291 memcpy (name
, p
, q
- p
);
295 append_include_chain (pfile
, pend
, name
, path
);
297 /* Advance past this name. */
305 /* Find the base name of a (partial) pathname FNAME.
306 Returns a pointer into the string passed in.
307 Accepts Unix (/-separated) paths on all systems,
308 DOS and VMS paths on those systems. */
313 char *s
= (char *)fname
;
315 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
316 if (ISALPHA (s
[0]) && s
[1] == ':') s
+= 2;
317 if ((p
= rindex (s
, '\\'))) s
= p
+ 1;
319 if ((p
= rindex (s
, ':'))) s
= p
+ 1; /* Skip device. */
320 if ((p
= rindex (s
, ']'))) s
= p
+ 1; /* Skip directory. */
321 if ((p
= rindex (s
, '>'))) s
= p
+ 1; /* Skip alternate (int'n'l) dir. */
323 if ((p
= rindex (s
, '/'))) s
= p
+ 1;
328 /* Append DIR to include path PATH. DIR must be permanently allocated
331 append_include_chain (pfile
, pend
, dir
, path
)
333 struct cpp_pending
*pend
;
337 struct file_name_list
*new;
341 simplify_pathname (dir
);
344 /* Dirs that don't exist are silently ignored. */
346 cpp_notice_from_errno (pfile
, dir
);
347 else if (CPP_OPTIONS (pfile
)->verbose
)
348 fprintf (stderr
, _("ignoring nonexistent directory `%s'\n"), dir
);
352 if (!S_ISDIR (st
.st_mode
))
354 cpp_notice (pfile
, "%s: Not a directory", dir
);
359 if (len
> pfile
->max_include_len
)
360 pfile
->max_include_len
= len
;
362 new = (struct file_name_list
*)xmalloc (sizeof (struct file_name_list
));
365 new->ino
= st
.st_ino
;
366 new->dev
= st
.st_dev
;
367 new->sysp
= (path
== SYSTEM
);
368 new->name_map
= NULL
;
374 case QUOTE
: APPEND (pend
, quote
, new); break;
375 case BRACKET
: APPEND (pend
, brack
, new); break;
376 case SYSTEM
: APPEND (pend
, systm
, new); break;
377 case AFTER
: APPEND (pend
, after
, new); break;
382 /* Write out a #define command for the special named MACRO_NAME
383 to PFILE's token_buffer. */
386 dump_special_to_buffer (pfile
, macro_name
)
388 const char *macro_name
;
390 static char define_directive
[] = "#define ";
391 int macro_name_length
= strlen (macro_name
);
392 output_line_command (pfile
, same_file
);
393 CPP_RESERVE (pfile
, sizeof(define_directive
) + macro_name_length
);
394 CPP_PUTS_Q (pfile
, define_directive
, sizeof(define_directive
)-1);
395 CPP_PUTS_Q (pfile
, macro_name
, macro_name_length
);
396 CPP_PUTC_Q (pfile
, ' ');
397 cpp_expand_to_buffer (pfile
, macro_name
, macro_name_length
);
398 CPP_PUTC (pfile
, '\n');
401 /* Initialize a cpp_options structure. */
403 cpp_options_init (opts
)
406 bzero ((char *) opts
, sizeof (struct cpp_options
));
408 opts
->dollars_in_ident
= 1;
409 opts
->cplusplus_comments
= 1;
410 opts
->warn_import
= 1;
413 (struct cpp_pending
*) xcalloc (1, sizeof (struct cpp_pending
));
416 /* Initialize a cpp_reader structure. */
418 cpp_reader_init (pfile
)
421 bzero ((char *) pfile
, sizeof (cpp_reader
));
423 pfile
->token_buffer_size
= 200;
424 pfile
->token_buffer
= (U_CHAR
*) xmalloc (pfile
->token_buffer_size
);
425 CPP_SET_WRITTEN (pfile
, 0);
427 pfile
->hashtab
= (HASHNODE
**) xcalloc (HASHSIZE
, sizeof (HASHNODE
*));
430 /* Free resources used by PFILE.
431 This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology). */
437 while (CPP_BUFFER (pfile
) != CPP_NULL_BUFFER (pfile
))
438 cpp_pop_buffer (pfile
);
440 if (pfile
->token_buffer
)
442 free (pfile
->token_buffer
);
443 pfile
->token_buffer
= NULL
;
446 if (pfile
->deps_buffer
)
448 free (pfile
->deps_buffer
);
449 pfile
->deps_buffer
= NULL
;
450 pfile
->deps_allocated_size
= 0;
453 if (pfile
->input_buffer
)
455 free (pfile
->input_buffer
);
456 free (pfile
->input_speccase
);
457 pfile
->input_buffer
= pfile
->input_speccase
= NULL
;
458 pfile
->input_buffer_len
= 0;
461 while (pfile
->if_stack
)
463 IF_STACK_FRAME
*temp
= pfile
->if_stack
;
464 pfile
->if_stack
= temp
->next
;
468 for (i
= ALL_INCLUDE_HASHSIZE
; --i
>= 0; )
470 struct include_hash
*imp
= pfile
->all_include_files
[i
];
473 struct include_hash
*next
= imp
->next
;
475 /* This gets freed elsewhere - I think. */
481 pfile
->all_include_files
[i
] = 0;
484 for (i
= HASHSIZE
; --i
>= 0;)
486 while (pfile
->hashtab
[i
])
487 delete_macro (pfile
->hashtab
[i
]);
489 free (pfile
->hashtab
);
493 /* This structure defines one built-in macro. A node of type TYPE will
494 be entered in the macro hash table under the name NAME, with value
495 VALUE (if any). FLAGS tweaks the behavior a little:
496 DUMP write debug info for this macro
497 STDC define only if not -traditional
498 ULP value is the global user_label_prefix (which can't be
499 put directly into the table).
507 unsigned short flags
;
513 static const struct builtin builtin_array
[] =
515 { "__TIME__", 0, T_TIME
, DUMP
},
516 { "__DATE__", 0, T_DATE
, DUMP
},
517 { "__FILE__", 0, T_FILE
, 0 },
518 { "__BASE_FILE__", 0, T_BASE_FILE
, DUMP
},
519 { "__LINE__", 0, T_SPECLINE
, 0 },
520 { "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL
, 0 },
521 { "__VERSION__", 0, T_VERSION
, DUMP
},
522 { "__STDC__", 0, T_STDC
, DUMP
|STDC
},
524 { "__USER_LABEL_PREFIX__", 0, T_CONST
, ULP
},
525 { "__REGISTER_PREFIX__", REGISTER_PREFIX
, T_CONST
, 0 },
526 { "__HAVE_BUILTIN_SETJMP__", "1", T_CONST
, 0 },
527 #ifndef NO_BUILTIN_SIZE_TYPE
528 { "__SIZE_TYPE__", SIZE_TYPE
, T_CONST
, DUMP
},
530 #ifndef NO_BUILTIN_PTRDIFF_TYPE
531 { "__PTRDIFF_TYPE__", PTRDIFF_TYPE
, T_CONST
, DUMP
},
533 { "__WCHAR_TYPE__", WCHAR_TYPE
, T_CONST
, DUMP
},
537 /* Subroutine of cpp_start_read; reads the builtins table above and
538 enters the macros into the hash table. */
541 initialize_builtins (pfile
)
545 const struct builtin
*b
;
547 for(b
= builtin_array
; b
->name
; b
++)
549 if ((b
->flags
& STDC
) && CPP_TRADITIONAL (pfile
))
552 val
= (b
->flags
& ULP
) ? user_label_prefix
: b
->value
;
553 len
= strlen (b
->name
);
555 cpp_install (pfile
, b
->name
, len
, b
->type
, val
, -1);
556 if ((b
->flags
& DUMP
) && CPP_OPTIONS (pfile
)->debug_output
)
557 dump_special_to_buffer (pfile
, b
->name
);
565 /* Another subroutine of cpp_start_read. This one sets up to do
566 dependency-file output. */
568 initialize_dependency_output (pfile
)
571 cpp_options
*opts
= CPP_OPTIONS (pfile
);
572 char *spec
, *s
, *output_file
;
574 /* Either of two environment variables can specify output of deps.
575 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
576 where OUTPUT_FILE is the file to write deps info to
577 and DEPS_TARGET is the target to mention in the deps. */
579 if (opts
->print_deps
== 0)
581 spec
= getenv ("DEPENDENCIES_OUTPUT");
583 opts
->print_deps
= 1;
586 spec
= getenv ("SUNPRO_DEPENDENCIES");
588 opts
->print_deps
= 2;
593 /* Find the space before the DEPS_TARGET, if there is one. */
594 s
= strchr (spec
, ' ');
597 opts
->deps_target
= s
+ 1;
598 output_file
= (char *) xmalloc (s
- spec
+ 1);
599 memcpy (output_file
, spec
, s
- spec
);
600 output_file
[s
- spec
] = 0;
604 opts
->deps_target
= 0;
608 opts
->deps_file
= output_file
;
609 opts
->print_deps_append
= 1;
612 /* Print the expected object file name as the target of this Make-rule. */
613 pfile
->deps_allocated_size
= 200;
614 pfile
->deps_buffer
= (char *) xmalloc (pfile
->deps_allocated_size
);
615 pfile
->deps_buffer
[0] = 0;
616 pfile
->deps_size
= 0;
617 pfile
->deps_column
= 0;
619 if (opts
->deps_target
)
620 deps_output (pfile
, opts
->deps_target
, ':');
621 else if (*opts
->in_fname
== 0)
622 deps_output (pfile
, "-", ':');
628 /* Discard all directory prefixes from filename. */
629 q
= base_name (opts
->in_fname
);
631 /* Copy remainder to mungable area. */
633 p
= (char *) alloca (len
+ 8);
636 /* Output P, but remove known suffixes. */
638 /* Point to the filename suffix. */
639 r
= strrchr (p
, '.');
641 /* Compare against the known suffixes. */
642 for (x
= 0; known_suffixes
[x
]; x
++)
643 if (strncmp (known_suffixes
[x
], r
, q
- r
) == 0)
645 /* Make q point to the bit we're going to overwrite
646 with an object suffix. */
651 /* Supply our own suffix. */
652 strcpy (q
, OBJECT_SUFFIX
);
654 deps_output (pfile
, p
, ':');
655 deps_output (pfile
, opts
->in_fname
, ' ');
659 /* This is called after options have been processed.
660 * Check options for consistency, and setup for processing input
661 * from the file named FNAME. (Use standard input if FNAME==NULL.)
662 * Return 1 on success, 0 on failure.
666 cpp_start_read (pfile
, fname
)
670 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
671 struct pending_option
*p
, *q
;
674 struct include_hash
*ih_fake
;
676 /* -MG doesn't select the form of output and must be specified with one of
677 -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
678 inhibit compilation. */
679 if (opts
->print_deps_missing_files
680 && (opts
->print_deps
== 0 || !opts
->no_output
))
682 cpp_fatal (pfile
, "-MG must be specified with one of -M or -MM");
686 /* Chill should not be used with -trigraphs. */
687 if (opts
->chill
&& opts
->trigraphs
)
689 cpp_warning (pfile
, "-lang-chill and -trigraphs are mutually exclusive");
693 /* Set this if it hasn't been set already. */
694 if (user_label_prefix
== NULL
)
695 user_label_prefix
= USER_LABEL_PREFIX
;
697 /* Now that we know dollars_in_ident, we can initialize the syntax
700 /* XXX Get rid of code that depends on this, then IStable can
702 if (opts
->dollars_in_ident
)
703 IStable
['$'] = ISidstart
|ISidnum
;
705 /* Do partial setup of input buffer for the sake of generating
706 early #line directives (when -g is in effect). */
707 fp
= cpp_push_buffer (pfile
, NULL
, 0);
710 if (opts
->in_fname
== NULL
|| *opts
->in_fname
== 0)
712 opts
->in_fname
= fname
;
713 if (opts
->in_fname
== NULL
)
716 fp
->nominal_fname
= fp
->fname
= opts
->in_fname
;
719 /* Install __LINE__, etc. Must follow initialize_char_syntax
720 and option processing. */
721 initialize_builtins (pfile
);
723 /* Do -U's, -D's and -A's in the order they were seen. */
724 p
= opts
->pending
->define_head
;
727 if (opts
->debug_output
)
728 output_line_command (pfile
, same_file
);
730 cpp_undef (pfile
, p
->arg
);
732 cpp_define (pfile
, p
->arg
);
739 p
= opts
->pending
->assert_head
;
742 if (opts
->debug_output
)
743 output_line_command (pfile
, same_file
);
745 cpp_unassert (pfile
, p
->arg
);
747 cpp_assert (pfile
, p
->arg
);
754 opts
->done_initializing
= 1;
756 /* Several environment variables may add to the include search path.
757 CPATH specifies an additional list of directories to be searched
758 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
759 etc. specify an additional list of directories to be searched as
760 if specified with -isystem, for the language indicated.
762 These variables are ignored if -nostdinc is on. */
763 if (! opts
->no_standard_includes
)
766 GET_ENV_PATH_LIST (path
, "CPATH");
767 if (path
!= 0 && *path
!= 0)
768 path_include (pfile
, opts
->pending
, path
, BRACKET
);
770 switch ((opts
->objc
<< 1) + opts
->cplusplus
)
773 GET_ENV_PATH_LIST (path
, "C_INCLUDE_PATH");
776 GET_ENV_PATH_LIST (path
, "CPLUS_INCLUDE_PATH");
779 GET_ENV_PATH_LIST (path
, "OBJC_INCLUDE_PATH");
782 GET_ENV_PATH_LIST (path
, "OBJCPLUS_INCLUDE_PATH");
785 if (path
!= 0 && *path
!= 0)
786 path_include (pfile
, opts
->pending
, path
, SYSTEM
);
789 /* Unless -nostdinc, add the compiled-in include path to the list,
790 translating prefixes. */
791 if (!opts
->no_standard_includes
)
793 struct default_include
*p
= include_defaults_array
;
794 char *specd_prefix
= opts
->include_prefix
;
796 /* Search "translated" versions of GNU directories.
797 These have /usr/local/lib/gcc... replaced by specd_prefix. */
798 if (specd_prefix
!= 0)
800 char *default_prefix
= alloca (sizeof GCC_INCLUDE_DIR
- 7);
801 /* Remove the `include' from /usr/local/lib/gcc.../include.
802 GCC_INCLUDE_DIR will always end in /include. */
803 int default_len
= sizeof GCC_INCLUDE_DIR
- 8;
804 int specd_len
= strlen (specd_prefix
);
806 memcpy (default_prefix
, GCC_INCLUDE_DIR
, default_len
);
807 default_prefix
[default_len
] = '\0';
809 for (p
= include_defaults_array
; p
->fname
; p
++)
811 /* Some standard dirs are only for C++. */
814 && !opts
->no_standard_cplusplus_includes
))
816 /* Does this dir start with the prefix? */
817 if (!strncmp (p
->fname
, default_prefix
, default_len
))
819 /* Yes; change prefix and add to search list. */
820 int flen
= strlen (p
->fname
);
821 int this_len
= specd_len
+ flen
- default_len
;
822 char *str
= (char *) xmalloc (this_len
+ 1);
823 memcpy (str
, specd_prefix
, specd_len
);
824 memcpy (str
+ specd_len
,
825 p
->fname
+ default_len
,
826 flen
- default_len
+ 1);
828 append_include_chain (pfile
, opts
->pending
,
835 /* Search ordinary names for GNU include directories. */
836 for (p
= include_defaults_array
; p
->fname
; p
++)
838 /* Some standard dirs are only for C++. */
841 && !opts
->no_standard_cplusplus_includes
))
843 /* XXX Potential memory leak! */
844 char *str
= xstrdup (update_path (p
->fname
, p
->component
));
845 append_include_chain (pfile
, opts
->pending
, str
, SYSTEM
);
850 merge_include_chains (opts
);
852 /* With -v, print the list of dirs to search. */
855 struct file_name_list
*p
;
856 fprintf (stderr
, _("#include \"...\" search starts here:\n"));
857 for (p
= opts
->quote_include
; p
; p
= p
->next
)
859 if (p
== opts
->bracket_include
)
860 fprintf (stderr
, _("#include <...> search starts here:\n"));
861 fprintf (stderr
, " %s\n", p
->name
);
863 fprintf (stderr
, _("End of search list.\n"));
866 /* Don't bother trying to do macro expansion if we've already done
868 if (opts
->preprocessed
)
869 pfile
->no_macro_expand
++;
871 /* Open the main input file.
872 We do this in nonblocking mode so we don't get stuck here if
873 someone clever has asked cpp to process /dev/rmt0;
874 finclude() will check that we have a real file to work with. */
875 if (fname
== NULL
|| *fname
== 0)
880 else if ((f
= open (fname
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666)) < 0)
882 cpp_notice_from_errno (pfile
, fname
);
886 initialize_dependency_output (pfile
);
888 /* Must call finclude() on the main input before processing
889 -include switches; otherwise the -included text winds up
890 after the main input. */
891 ih_fake
= (struct include_hash
*) xmalloc (sizeof (struct include_hash
));
893 ih_fake
->next_this_file
= 0;
894 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
895 ih_fake
->name
= fname
;
896 ih_fake
->control_macro
= 0;
897 ih_fake
->buf
= (char *)-1;
899 if (!finclude (pfile
, f
, ih_fake
))
901 if (opts
->preprocessed
)
902 /* If we've already processed this code, we want to trust the #line
903 directives in the input. But we still need to update our line
904 counter accordingly. */
905 pfile
->lineno
= CPP_BUFFER (pfile
)->lineno
;
907 output_line_command (pfile
, same_file
);
908 pfile
->only_seen_white
= 2;
910 /* The -imacros files can be scanned now, but the -include files
911 have to be pushed onto the include stack and processed later,
912 in the main loop calling cpp_get_token. */
914 pfile
->no_record_file
++;
916 p
= opts
->pending
->imacros_head
;
919 int fd
= open (p
->arg
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666);
922 cpp_notice_from_errno (pfile
, p
->arg
);
925 if (!cpp_push_buffer (pfile
, NULL
, 0))
928 ih_fake
= (struct include_hash
*)
929 xmalloc (sizeof (struct include_hash
));
931 ih_fake
->next_this_file
= 0;
932 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
933 ih_fake
->name
= p
->arg
;
934 ih_fake
->control_macro
= 0;
935 ih_fake
->buf
= (char *)-1;
937 if (finclude (pfile
, fd
, ih_fake
))
939 if (CPP_PRINT_DEPS (pfile
))
940 deps_output (pfile
, ih_fake
->name
, ' ');
942 cpp_scan_buffer (pfile
);
945 cpp_pop_buffer (pfile
);
955 p
= opts
->pending
->include_head
;
958 int fd
= open (p
->arg
, O_RDONLY
|O_NONBLOCK
|O_NOCTTY
, 0666);
961 cpp_notice_from_errno (pfile
, p
->arg
);
964 if (!cpp_push_buffer (pfile
, NULL
, 0))
967 ih_fake
= (struct include_hash
*)
968 xmalloc (sizeof (struct include_hash
));
970 ih_fake
->next_this_file
= 0;
971 ih_fake
->foundhere
= ABSOLUTE_PATH
; /* well sort of ... */
972 ih_fake
->name
= p
->arg
;
973 ih_fake
->control_macro
= 0;
974 ih_fake
->buf
= (char *)-1;
976 if (finclude (pfile
, fd
, ih_fake
))
978 if (CPP_PRINT_DEPS (pfile
))
979 deps_output (pfile
, ih_fake
->name
, ' ');
981 output_line_command (pfile
, enter_file
);
984 cpp_pop_buffer (pfile
);
989 pfile
->no_record_file
--;
991 free (opts
->pending
);
992 opts
->pending
= NULL
;
997 /* This is called at the end of preprocessing. It pops the
998 last buffer and writes dependency output. It should also
999 clear macro definitions, such that you could call cpp_start_read
1000 with a new filename to restart processing. */
1005 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
1007 if (CPP_PREV_BUFFER (CPP_BUFFER (pfile
)) != CPP_NULL_BUFFER (pfile
))
1008 cpp_ice (pfile
, "buffers still stacked in cpp_finish");
1009 cpp_pop_buffer (pfile
);
1011 if (opts
->print_deps
)
1013 /* Stream on which to print the dependency information. */
1014 FILE *deps_stream
= 0;
1016 /* Don't actually write the deps file if compilation has failed. */
1017 if (pfile
->errors
== 0)
1019 const char *deps_mode
= opts
->print_deps_append
? "a" : "w";
1020 if (opts
->deps_file
== 0)
1021 deps_stream
= stdout
;
1022 else if ((deps_stream
= fopen (opts
->deps_file
, deps_mode
)) == 0)
1023 cpp_notice_from_errno (pfile
, opts
->deps_file
);
1027 fputs (pfile
->deps_buffer
, deps_stream
);
1028 putc ('\n', deps_stream
);
1029 if (opts
->deps_file
)
1031 if (ferror (deps_stream
) || fclose (deps_stream
) != 0)
1032 cpp_fatal (pfile
, "I/O error on output");
1038 if (opts
->dump_macros
== dump_only
)
1043 for (i
= HASHSIZE
; --i
>= 0;)
1045 for (h
= pfile
->hashtab
[i
]; h
; h
= h
->next
)
1046 if (h
->type
== T_MACRO
)
1048 m
.defn
= h
->value
.defn
;
1050 m
.symlen
= h
->length
;
1051 dump_definition (pfile
, m
);
1052 CPP_PUTC (pfile
, '\n');
1059 new_pending_define (opts
, text
)
1060 struct cpp_options
*opts
;
1063 struct pending_option
*o
= (struct pending_option
*)
1064 xmalloc (sizeof (struct pending_option
));
1069 APPEND (opts
->pending
, define
, o
);
1072 /* Handle one command-line option in (argc, argv).
1073 Can be called multiple times, to handle multiple sets of options.
1074 Returns number of strings consumed. */
1076 cpp_handle_option (pfile
, argc
, argv
)
1081 struct cpp_options
*opts
= CPP_OPTIONS (pfile
);
1084 if (argv
[i
][0] != '-')
1086 if (opts
->out_fname
!= NULL
)
1089 cpp_fatal (pfile
, "Too many arguments");
1091 else if (opts
->in_fname
!= NULL
)
1092 opts
->out_fname
= argv
[i
];
1094 opts
->in_fname
= argv
[i
];
1100 if (!strcmp (argv
[i
], "-fleading-underscore"))
1101 user_label_prefix
= "_";
1102 else if (!strcmp (argv
[i
], "-fno-leading-underscore"))
1103 user_label_prefix
= "";
1104 else if (!strcmp (argv
[i
], "-fpreprocessed"))
1105 opts
->preprocessed
= 1;
1106 else if (!strcmp (argv
[i
], "-fno-preprocessed"))
1107 opts
->preprocessed
= 0;
1114 case 'I': /* Add directory to path for includes. */
1115 if (!strcmp (argv
[i
] + 2, "-"))
1118 Use the preceding -I directories for #include "..."
1119 but not #include <...>.
1120 Don't search the directory of the present file
1121 for #include "...". (Note that -I. -I- is not the same as
1122 the default setup; -I. uses the compiler's working dir.) */
1123 if (! opts
->ignore_srcdir
)
1125 opts
->ignore_srcdir
= 1;
1126 opts
->pending
->quote_head
= opts
->pending
->brack_head
;
1127 opts
->pending
->quote_tail
= opts
->pending
->brack_tail
;
1128 opts
->pending
->brack_head
= 0;
1129 opts
->pending
->brack_tail
= 0;
1133 cpp_fatal (pfile
, "-I- specified twice");
1140 if (argv
[i
][2] != 0)
1141 fname
= argv
[i
] + 2;
1142 else if (i
+ 1 == argc
)
1143 goto missing_dirname
;
1146 append_include_chain (pfile
, opts
->pending
,
1147 xstrdup (fname
), BRACKET
);
1152 /* Add directory to beginning of system include path, as a system
1153 include directory. */
1154 if (!strcmp (argv
[i
], "-isystem"))
1157 goto missing_filename
;
1158 append_include_chain (pfile
, opts
->pending
,
1159 xstrdup (argv
[++i
]), SYSTEM
);
1161 else if (!strcmp (argv
[i
], "-include"))
1164 goto missing_filename
;
1167 struct pending_option
*o
= (struct pending_option
*)
1168 xmalloc (sizeof (struct pending_option
));
1171 /* This list has to be built in reverse order so that
1172 when cpp_start_read pushes all the -include files onto
1173 the buffer stack, they will be scanned in forward order. */
1174 o
->next
= opts
->pending
->include_head
;
1175 opts
->pending
->include_head
= o
;
1178 else if (!strcmp (argv
[i
], "-imacros"))
1181 goto missing_filename
;
1184 struct pending_option
*o
= (struct pending_option
*)
1185 xmalloc (sizeof (struct pending_option
));
1189 APPEND (opts
->pending
, imacros
, o
);
1192 /* Add directory to end of path for includes,
1193 with the default prefix at the front of its name. */
1194 else if (!strcmp (argv
[i
], "-iwithprefix"))
1199 goto missing_dirname
;
1201 len
= strlen (argv
[i
]);
1203 if (opts
->include_prefix
!= 0)
1205 fname
= xmalloc (opts
->include_prefix_len
+ len
+ 1);
1206 memcpy (fname
, opts
->include_prefix
, opts
->include_prefix_len
);
1207 memcpy (fname
+ opts
->include_prefix_len
, argv
[i
], len
+ 1);
1211 fname
= xmalloc (sizeof GCC_INCLUDE_DIR
- 8 + len
);
1212 memcpy (fname
, GCC_INCLUDE_DIR
, sizeof GCC_INCLUDE_DIR
- 9);
1213 memcpy (fname
+ sizeof GCC_INCLUDE_DIR
- 9, argv
[i
], len
+ 1);
1216 append_include_chain (pfile
, opts
->pending
, fname
, SYSTEM
);
1218 /* Add directory to main path for includes,
1219 with the default prefix at the front of its name. */
1220 else if (!strcmp (argv
[i
], "-iwithprefixbefore"))
1225 goto missing_dirname
;
1227 len
= strlen (argv
[i
]);
1229 if (opts
->include_prefix
!= 0)
1231 fname
= xmalloc (opts
->include_prefix_len
+ len
+ 1);
1232 memcpy (fname
, opts
->include_prefix
, opts
->include_prefix_len
);
1233 memcpy (fname
+ opts
->include_prefix_len
, argv
[i
], len
+ 1);
1237 fname
= xmalloc (sizeof GCC_INCLUDE_DIR
- 8 + len
);
1238 memcpy (fname
, GCC_INCLUDE_DIR
, sizeof GCC_INCLUDE_DIR
- 9);
1239 memcpy (fname
+ sizeof GCC_INCLUDE_DIR
- 9, argv
[i
], len
+ 1);
1242 append_include_chain (pfile
, opts
->pending
, fname
, BRACKET
);
1244 /* Add directory to end of path for includes. */
1245 else if (!strcmp (argv
[i
], "-idirafter"))
1248 goto missing_dirname
;
1249 append_include_chain (pfile
, opts
->pending
,
1250 xstrdup (argv
[++i
]), AFTER
);
1252 else if (!strcmp (argv
[i
], "-iprefix"))
1255 goto missing_filename
;
1258 opts
->include_prefix
= argv
[++i
];
1259 opts
->include_prefix_len
= strlen (argv
[i
]);
1262 else if (!strcmp (argv
[i
], "-ifoutput"))
1263 opts
->output_conditionals
= 1;
1268 if (opts
->out_fname
!= NULL
)
1270 cpp_fatal (pfile
, "Output filename specified twice");
1274 goto missing_filename
;
1275 opts
->out_fname
= argv
[++i
];
1276 if (!strcmp (opts
->out_fname
, "-"))
1277 opts
->out_fname
= "";
1281 if (!strcmp (argv
[i
], "-pedantic"))
1282 CPP_PEDANTIC (pfile
) = 1;
1283 else if (!strcmp (argv
[i
], "-pedantic-errors"))
1285 CPP_PEDANTIC (pfile
) = 1;
1286 opts
->pedantic_errors
= 1;
1291 if (!strcmp (argv
[i
], "-traditional"))
1293 opts
->traditional
= 1;
1294 opts
->cplusplus_comments
= 0;
1295 opts
->trigraphs
= 0;
1296 opts
->warn_trigraphs
= 0;
1298 else if (!strcmp (argv
[i
], "-trigraphs"))
1299 opts
->trigraphs
= 1;
1303 if (! strcmp (argv
[i
], "-lang-c"))
1304 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1305 opts
->c99
= 1, opts
->objc
= 0;
1306 if (! strcmp (argv
[i
], "-lang-c89"))
1308 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1309 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1310 opts
->trigraphs
= 1;
1311 new_pending_define (opts
, "__STRICT_ANSI__");
1313 if (! strcmp (argv
[i
], "-lang-c++"))
1314 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1315 opts
->c99
= 0, opts
->objc
= 0;
1316 if (! strcmp (argv
[i
], "-lang-objc"))
1317 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1318 opts
->c99
= 0, opts
->objc
= 1;
1319 if (! strcmp (argv
[i
], "-lang-objc++"))
1320 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1, opts
->c89
= 0,
1321 opts
->c99
= 0, opts
->objc
= 1;
1322 if (! strcmp (argv
[i
], "-lang-asm"))
1324 if (! strcmp (argv
[i
], "-lang-fortran"))
1325 opts
->lang_fortran
= 1, opts
->cplusplus_comments
= 0;
1326 if (! strcmp (argv
[i
], "-lang-chill"))
1327 opts
->objc
= 0, opts
->cplusplus
= 0, opts
->chill
= 1,
1328 opts
->traditional
= 1;
1332 opts
->cplusplus
= 1, opts
->cplusplus_comments
= 1;
1336 if (!strcmp (argv
[i
], "-std=gnu89"))
1338 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1339 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1341 else if (!strcmp (argv
[i
], "-std=gnu9x")
1342 || !strcmp (argv
[i
], "-std=gnu99"))
1344 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1345 opts
->c89
= 0, opts
->c99
= 1, opts
->objc
= 0;
1346 new_pending_define (opts
, "__STDC_VERSION__=199901L");
1348 else if (!strcmp (argv
[i
], "-std=iso9899:1990")
1349 || !strcmp (argv
[i
], "-std=c89"))
1351 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1352 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1353 opts
->trigraphs
= 1;
1354 new_pending_define (opts
, "__STRICT_ANSI__");
1356 else if (!strcmp (argv
[i
], "-std=iso9899:199409"))
1358 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 0;
1359 opts
->c89
= 1, opts
->c99
= 0, opts
->objc
= 0;
1360 opts
->trigraphs
= 1;
1361 new_pending_define (opts
, "__STRICT_ANSI__");
1362 new_pending_define (opts
, "__STDC_VERSION__=199409L");
1364 else if (!strcmp (argv
[i
], "-std=iso9899:199x")
1365 || !strcmp (argv
[i
], "-std=iso9899:1999")
1366 || !strcmp (argv
[i
], "-std=c9x")
1367 || !strcmp (argv
[i
], "-std=c99"))
1369 opts
->cplusplus
= 0, opts
->cplusplus_comments
= 1;
1370 opts
->c89
= 0, opts
->c99
= 1, opts
->objc
= 0;
1371 opts
->trigraphs
= 1;
1372 new_pending_define (opts
, "__STRICT_ANSI__");
1373 new_pending_define (opts
, "__STDC_VERSION__=199901L");
1378 opts
->inhibit_warnings
= 1;
1382 if (!strcmp (argv
[i
], "-Wtrigraphs"))
1383 opts
->warn_trigraphs
= 1;
1384 else if (!strcmp (argv
[i
], "-Wno-trigraphs"))
1385 opts
->warn_trigraphs
= 0;
1386 else if (!strcmp (argv
[i
], "-Wcomment"))
1387 opts
->warn_comments
= 1;
1388 else if (!strcmp (argv
[i
], "-Wno-comment"))
1389 opts
->warn_comments
= 0;
1390 else if (!strcmp (argv
[i
], "-Wcomments"))
1391 opts
->warn_comments
= 1;
1392 else if (!strcmp (argv
[i
], "-Wno-comments"))
1393 opts
->warn_comments
= 0;
1394 else if (!strcmp (argv
[i
], "-Wtraditional"))
1395 opts
->warn_stringify
= 1;
1396 else if (!strcmp (argv
[i
], "-Wno-traditional"))
1397 opts
->warn_stringify
= 0;
1398 else if (!strcmp (argv
[i
], "-Wundef"))
1399 opts
->warn_undef
= 1;
1400 else if (!strcmp (argv
[i
], "-Wno-undef"))
1401 opts
->warn_undef
= 0;
1402 else if (!strcmp (argv
[i
], "-Wimport"))
1403 opts
->warn_import
= 1;
1404 else if (!strcmp (argv
[i
], "-Wno-import"))
1405 opts
->warn_import
= 0;
1406 else if (!strcmp (argv
[i
], "-Werror"))
1407 opts
->warnings_are_errors
= 1;
1408 else if (!strcmp (argv
[i
], "-Wno-error"))
1409 opts
->warnings_are_errors
= 0;
1410 else if (!strcmp (argv
[i
], "-Wall"))
1412 opts
->warn_trigraphs
= 1;
1413 opts
->warn_comments
= 1;
1418 /* The style of the choices here is a bit mixed.
1419 The chosen scheme is a hybrid of keeping all options in one string
1420 and specifying each option in a separate argument:
1421 -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
1422 -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
1423 -M[M][G][D file]. This is awkward to handle in specs, and is not
1425 /* ??? -MG must be specified in addition to one of -M or -MM.
1426 This can be relaxed in the future without breaking anything.
1427 The converse isn't true. */
1429 /* -MG isn't valid with -MD or -MMD. This is checked for later. */
1430 if (!strcmp (argv
[i
], "-MG"))
1432 opts
->print_deps_missing_files
= 1;
1435 if (!strcmp (argv
[i
], "-M"))
1436 opts
->print_deps
= 2;
1437 else if (!strcmp (argv
[i
], "-MM"))
1438 opts
->print_deps
= 1;
1439 else if (!strcmp (argv
[i
], "-MD"))
1440 opts
->print_deps
= 2;
1441 else if (!strcmp (argv
[i
], "-MMD"))
1442 opts
->print_deps
= 1;
1443 /* For -MD and -MMD options, write deps on file named by next arg. */
1444 if (!strcmp (argv
[i
], "-MD") || !strcmp (argv
[i
], "-MMD"))
1447 goto missing_filename
;
1448 opts
->deps_file
= argv
[++i
];
1452 /* For -M and -MM, write deps on standard output
1453 and suppress the usual output. */
1454 opts
->no_output
= 1;
1460 char *p
= argv
[i
] + 2;
1462 while ((c
= *p
++) != 0)
1464 /* Arg to -d specifies what parts of macros to dump */
1468 opts
->dump_macros
= dump_only
;
1469 opts
->no_output
= 1;
1472 opts
->dump_macros
= dump_names
;
1475 opts
->dump_macros
= dump_definitions
;
1478 opts
->dump_includes
= 1;
1486 if (argv
[i
][2] == '3')
1487 opts
->debug_output
= 1;
1491 if (!strcmp (argv
[i
], "--help"))
1493 else if (!strcmp (argv
[i
], "--version"))
1494 fprintf (stderr
, _("GNU CPP version %s (cpplib)\n"), version_string
);
1499 fprintf (stderr
, _("GNU CPP version %s (cpplib)\n"), version_string
);
1500 #ifdef TARGET_VERSION
1503 fputc ('\n', stderr
);
1508 opts
->print_include_names
= 1;
1514 if (argv
[i
][2] != 0)
1516 else if (i
+ 1 == argc
)
1518 cpp_fatal (pfile
, "Macro name missing after -D option");
1523 new_pending_define (opts
, text
);
1531 if (argv
[i
][2] != 0)
1533 else if (i
+ 1 == argc
)
1535 cpp_fatal (pfile
, "Assertion missing after -A option");
1541 if (strcmp (p
, "-"))
1543 struct pending_option
*o
= (struct pending_option
*)
1544 xmalloc (sizeof (struct pending_option
));
1549 APPEND (opts
->pending
, assert, o
);
1553 /* -A- eliminates all predefined macros and assertions.
1554 Let's include also any that were specified earlier
1555 on the command line. That way we can get rid of any
1556 that were passed automatically in from GCC. */
1557 struct pending_option
*o1
, *o2
;
1559 o1
= opts
->pending
->define_head
;
1566 o1
= opts
->pending
->assert_head
;
1573 opts
->pending
->assert_head
= NULL
;
1574 opts
->pending
->assert_tail
= NULL
;
1575 opts
->pending
->define_head
= NULL
;
1576 opts
->pending
->define_tail
= NULL
;
1583 struct pending_option
*o
= (struct pending_option
*)
1584 xmalloc (sizeof (struct pending_option
));
1586 if (argv
[i
][2] != 0)
1587 o
->arg
= argv
[i
] + 2;
1588 else if (i
+ 1 == argc
)
1590 cpp_fatal (pfile
, "Macro name missing after -U option");
1598 APPEND (opts
->pending
, define
, o
);
1603 opts
->put_out_comments
= 1;
1606 case 'E': /* -E comes from cc -E; ignore it. */
1610 opts
->no_line_commands
= 1;
1613 case '$': /* Don't include $ in identifiers. */
1614 opts
->dollars_in_ident
= 0;
1618 if (!strcmp (argv
[i
], "-nostdinc"))
1619 /* -nostdinc causes no default include directories.
1620 You must specify all include-file directories with -I. */
1621 opts
->no_standard_includes
= 1;
1622 else if (!strcmp (argv
[i
], "-nostdinc++"))
1623 /* -nostdinc++ causes no default C++-specific include directories. */
1624 opts
->no_standard_cplusplus_includes
= 1;
1628 if (!strcmp (argv
[i
], "-remap"))
1632 case '\0': /* JF handle '-' as file name meaning stdin or stdout */
1633 if (opts
->in_fname
== NULL
)
1634 opts
->in_fname
= "";
1635 else if (opts
->out_fname
== NULL
)
1636 opts
->out_fname
= "";
1638 return i
; /* error */
1648 cpp_fatal (pfile
, "Filename missing after `%s' option", argv
[i
]);
1651 cpp_fatal (pfile
, "Directory name missing after `%s' option", argv
[i
]);
1655 /* Handle command-line options in (argc, argv).
1656 Can be called multiple times, to handle multiple sets of options.
1657 Returns if an unrecognized option is seen.
1658 Returns number of strings consumed. */
1661 cpp_handle_options (pfile
, argc
, argv
)
1667 int strings_processed
;
1668 for (i
= 0; i
< argc
; i
+= strings_processed
)
1670 strings_processed
= cpp_handle_option (pfile
, argc
- i
, argv
+ i
);
1671 if (strings_processed
== 0)
1680 fprintf (stderr
, _("Usage: %s [switches] input output\n"), progname
);
1683 -include <file> Include the contents of <file> before other files\n\
1684 -imacros <file> Accept definition of macros in <file>\n\
1685 -iprefix <path> Specify <path> as a prefix for next two options\n\
1686 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1687 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1688 -isystem <dir> Add <dir> to the start of the system include path\n\
1689 -idirafter <dir> Add <dir> to the end of the system include path\n\
1690 -I <dir> Add <dir> to the end of the main include path\n\
1691 -nostdinc Do not search system include directories\n\
1692 (dirs specified with -isystem will still be used)\n\
1693 -nostdinc++ Do not search system include directories for C++\n\
1694 -o <file> Put output into <file>\n\
1695 -pedantic Issue all warnings demanded by strict ANSI C\n\
1696 -traditional Follow K&R pre-processor behaviour\n\
1697 -trigraphs Support ANSI C trigraphs\n\
1698 -lang-c Assume that the input sources are in C\n\
1699 -lang-c89 Assume that the input sources are in C89\n\
1700 -lang-c++ Assume that the input sources are in C++\n\
1701 -lang-objc Assume that the input sources are in ObjectiveC\n\
1702 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1703 -lang-asm Assume that the input sources are in assembler\n\
1704 -lang-fortran Assume that the input sources are in Fortran\n\
1705 -lang-chill Assume that the input sources are in Chill\n\
1706 -std=<std name> Specify the conformance standard; one of:\n\
1707 gnu89, gnu99, c89, c99, iso9899:1990,\n\
1708 iso9899:199409, iso9899:1999\n\
1709 -+ Allow parsing of C++ style features\n\
1710 -w Inhibit warning messages\n\
1711 -Wtrigraphs Warn if trigraphs are encountered\n\
1712 -Wno-trigraphs Do not warn about trigraphs\n\
1713 -Wcomment{s} Warn if one comment starts inside another\n\
1714 -Wno-comment{s} Do not warn about comments\n\
1715 -Wtraditional Warn if a macro argument is/would be turned into\n\
1716 a string if -traditional is specified\n\
1717 -Wno-traditional Do not warn about stringification\n\
1718 -Wundef Warn if an undefined macro is used by #if\n\
1719 -Wno-undef Do not warn about testing undefined macros\n\
1720 -Wimport Warn about the use of the #import directive\n\
1721 -Wno-import Do not warn about the use of #import\n\
1722 -Werror Treat all warnings as errors\n\
1723 -Wno-error Do not treat warnings as errors\n\
1724 -Wall Enable all preprocessor warnings\n\
1725 -M Generate make dependencies\n\
1726 -MM As -M, but ignore system header files\n\
1727 -MD As -M, but put output in a .d file\n\
1728 -MMD As -MD, but ignore system header files\n\
1729 -MG Treat missing header file as generated files\n\
1730 -g Include #define and #undef directives in the output\n\
1731 -D<macro> Define a <macro> with string '1' as its value\n\
1732 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1733 -A<question> (<answer>) Assert the <answer> to <question>\n\
1734 -U<macro> Undefine <macro> \n\
1735 -v Display the version number\n\
1736 -H Print the name of header files as they are used\n\
1737 -C Do not discard comments\n\
1738 -dM Display a list of macro definitions active at end\n\
1739 -dD Preserve macro definitions in output\n\
1740 -dN As -dD except that only the names are preserved\n\
1741 -dI Include #include directives in the output\n\
1742 -ifoutput Describe skipped code blocks in output \n\
1743 -P Do not generate #line directives\n\
1744 -$ Do not allow '$' in identifiers\n\
1745 -remap Remap file names when including files.\n\
1746 -h or --help Display this information\n\