]> gcc.gnu.org Git - gcc.git/blame - gcc/cppinit.c
sizeof3.C: Remove XFAILS.
[gcc.git] / gcc / cppinit.c
CommitLineData
5538ada6
ZW
1/* CPP Library.
2 Copyright (C) 1986, 87, 89, 92-98, 1999 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
6
7This program is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 2, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
5538ada6
ZW
21#include "config.h"
22#include "system.h"
23
6de1e2a9
ZW
24#define FAKE_CONST
25#include "cpplib.h"
26#include "cpphash.h"
27#include "output.h"
28#include "prefix.h"
29#include "intl.h"
5538ada6 30
6de1e2a9
ZW
31/* XXX Should be in a header file. */
32extern char *version_string;
33
34/* Predefined symbols, built-in macros, and the default include path. */
35
36#ifndef GET_ENV_PATH_LIST
37#define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0)
38#endif
39
40/* By default, colon separates directories in a path. */
41#ifndef PATH_SEPARATOR
42#define PATH_SEPARATOR ':'
43#endif
44
45#ifndef STANDARD_INCLUDE_DIR
46#define STANDARD_INCLUDE_DIR "/usr/include"
47#endif
48
6de1e2a9
ZW
49/* We let tm.h override the types used here, to handle trivial differences
50 such as the choice of unsigned int or long unsigned int for size_t.
51 When machines start needing nontrivial differences in the size type,
52 it would be best to do something here to figure out automatically
53 from other information what type to use. */
54
55/* The string value for __SIZE_TYPE__. */
56
57#ifndef SIZE_TYPE
58#define SIZE_TYPE "long unsigned int"
59#endif
60
61/* The string value for __PTRDIFF_TYPE__. */
62
63#ifndef PTRDIFF_TYPE
64#define PTRDIFF_TYPE "long int"
65#endif
66
67/* The string value for __WCHAR_TYPE__. */
68
69#ifndef WCHAR_TYPE
70#define WCHAR_TYPE "int"
71#endif
72#define CPP_WCHAR_TYPE(PFILE) \
73 (CPP_OPTIONS (PFILE)->cplusplus ? "__wchar_t" : WCHAR_TYPE)
74
75/* The string value for __USER_LABEL_PREFIX__ */
76
77#ifndef USER_LABEL_PREFIX
78#define USER_LABEL_PREFIX ""
79#endif
80
81/* The string value for __REGISTER_PREFIX__ */
82
83#ifndef REGISTER_PREFIX
84#define REGISTER_PREFIX ""
85#endif
86
0b22d65c 87/* Suffix for object files, and known input-file extensions. */
bcc5cac9 88static const char * const known_suffixes[] =
0b22d65c
ZW
89{
90 ".c", ".C", ".s", ".S", ".m",
91 ".cc", ".cxx", ".cpp", ".cp", ".c++",
92 NULL
93};
94
95#ifndef OBJECT_SUFFIX
96# ifdef VMS
97# define OBJECT_SUFFIX ".obj"
98# else
99# define OBJECT_SUFFIX ".o"
100# endif
101#endif
102
103
104/* This is the default list of directories to search for include files.
105 It may be overridden by the various -I and -ixxx options.
106
107 #include "file" looks in the same directory as the current file,
108 then this list.
109 #include <file> just looks in this list.
110
111 All these directories are treated as `system' include directories
112 (they are not subject to pedantic warnings in some cases). */
113
114static struct default_include
115{
bcc5cac9
KG
116 const char *fname; /* The name of the directory. */
117 const char *component; /* The component containing the directory
0b22d65c 118 (see update_path in prefix.c) */
6de1e2a9
ZW
119 int cplusplus; /* Only look here if we're compiling C++. */
120 int cxx_aware; /* Includes in this directory don't need to
121 be wrapped in extern "C" when compiling
0b22d65c
ZW
122 C++. This is not used anymore. */
123}
124include_defaults_array[]
6de1e2a9 125#ifdef INCLUDE_DEFAULTS
0b22d65c 126= INCLUDE_DEFAULTS;
6de1e2a9 127#else
0b22d65c 128= {
6de1e2a9
ZW
129 /* Pick up GNU C++ specific include files. */
130 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
131#ifdef CROSS_COMPILE
132 /* This is the dir for fixincludes. Put it just before
133 the files that we fix. */
134 { GCC_INCLUDE_DIR, "GCC", 0, 0 },
135 /* For cross-compilation, this dir name is generated
136 automatically in Makefile.in. */
0b22d65c 137 { CROSS_INCLUDE_DIR, "GCC", 0, 0 },
6de1e2a9
ZW
138#ifdef TOOL_INCLUDE_DIR
139 /* This is another place that the target system's headers might be. */
140 { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
141#endif
142#else /* not CROSS_COMPILE */
143#ifdef LOCAL_INCLUDE_DIR
144 /* This should be /usr/local/include and should come before
145 the fixincludes-fixed header files. */
146 { LOCAL_INCLUDE_DIR, 0, 0, 1 },
147#endif
148#ifdef TOOL_INCLUDE_DIR
149 /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here.
150 Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */
151 { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
152#endif
153 /* This is the dir for fixincludes. Put it just before
154 the files that we fix. */
155 { GCC_INCLUDE_DIR, "GCC", 0, 0 },
156 /* Some systems have an extra dir of include files. */
157#ifdef SYSTEM_INCLUDE_DIR
158 { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
159#endif
160#ifndef STANDARD_INCLUDE_COMPONENT
161#define STANDARD_INCLUDE_COMPONENT 0
162#endif
163 { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
164#endif /* not CROSS_COMPILE */
165 { 0, 0, 0, 0 }
0b22d65c 166 };
6de1e2a9
ZW
167#endif /* no INCLUDE_DEFAULTS */
168
169/* Internal structures and prototypes. */
170
0b22d65c
ZW
171/* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
172 switch. There are four lists: one for -D and -U, one for -A, one
173 for -include, one for -imacros. `undef' is set for -U, clear for
174 -D, ignored for the others.
175 (Future: add an equivalent of -U for -A) */
176struct pending_option
6de1e2a9 177{
0b22d65c 178 struct pending_option *next;
6de1e2a9 179 char *arg;
0b22d65c 180 int undef;
6de1e2a9 181};
0b22d65c
ZW
182
183#ifdef __STDC__
184#define APPEND(pend, list, elt) \
185 do { if (!(pend)->list##_head) (pend)->list##_head = (elt); \
186 else (pend)->list##_tail->next = (elt); \
187 (pend)->list##_tail = (elt); \
188 } while (0)
189#else
190#define APPEND(pend, list, elt) \
191 do { if (!(pend)->list/**/_head) (pend)->list/**/_head = (elt); \
192 else (pend)->list/**/_tail->next = (elt); \
193 (pend)->list/**/_tail = (elt); \
194 } while (0)
195#endif
6de1e2a9
ZW
196
197static void initialize_char_syntax PARAMS ((int));
198static void print_help PARAMS ((void));
0b22d65c
ZW
199static void path_include PARAMS ((cpp_reader *,
200 struct cpp_pending *,
201 char *, int));
6de1e2a9 202static void initialize_builtins PARAMS ((cpp_reader *));
0b22d65c
ZW
203static void append_include_chain PARAMS ((cpp_reader *,
204 struct cpp_pending *,
205 char *, int));
bcc5cac9
KG
206static char *base_name PARAMS ((const char *));
207static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *));
208static void initialize_dependency_output PARAMS ((cpp_reader *));
6de1e2a9 209
0b22d65c
ZW
210/* Last argument to append_include_chain: chain to use */
211enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
6de1e2a9
ZW
212
213/* If gcc is in use (stage2/stage3) we can make these tables initialized
214 data. */
215#if defined __GNUC__ && __GNUC__ >= 2
216/* Table to tell if a character is legal as the second or later character
217 of a C identifier. */
218U_CHAR is_idchar[256] =
219{
220 ['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1, ['e'] = 1, ['f'] = 1,
221 ['g'] = 1, ['h'] = 1, ['i'] = 1, ['j'] = 1, ['k'] = 1, ['l'] = 1,
222 ['m'] = 1, ['n'] = 1, ['o'] = 1, ['p'] = 1, ['q'] = 1, ['r'] = 1,
223 ['s'] = 1, ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1,
224 ['y'] = 1, ['z'] = 1,
225
226 ['A'] = 1, ['B'] = 1, ['C'] = 1, ['D'] = 1, ['E'] = 1, ['F'] = 1,
227 ['G'] = 1, ['H'] = 1, ['I'] = 1, ['J'] = 1, ['K'] = 1, ['L'] = 1,
228 ['M'] = 1, ['N'] = 1, ['O'] = 1, ['P'] = 1, ['Q'] = 1, ['R'] = 1,
229 ['S'] = 1, ['T'] = 1, ['U'] = 1, ['V'] = 1, ['W'] = 1, ['X'] = 1,
230 ['Y'] = 1, ['Z'] = 1,
231
232 ['1'] = 1, ['2'] = 1, ['3'] = 1, ['4'] = 1, ['5'] = 1, ['6'] = 1,
233 ['7'] = 1, ['8'] = 1, ['9'] = 1, ['0'] = 1,
234
235 ['_'] = 1,
236};
237
238/* Table to tell if a character is legal as the first character of
239 a C identifier. */
240U_CHAR is_idstart[256] =
241{
242 ['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1, ['e'] = 1, ['f'] = 1,
243 ['g'] = 1, ['h'] = 1, ['i'] = 1, ['j'] = 1, ['k'] = 1, ['l'] = 1,
244 ['m'] = 1, ['n'] = 1, ['o'] = 1, ['p'] = 1, ['q'] = 1, ['r'] = 1,
245 ['s'] = 1, ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1,
246 ['y'] = 1, ['z'] = 1,
247
248 ['A'] = 1, ['B'] = 1, ['C'] = 1, ['D'] = 1, ['E'] = 1, ['F'] = 1,
249 ['G'] = 1, ['H'] = 1, ['I'] = 1, ['J'] = 1, ['K'] = 1, ['L'] = 1,
250 ['M'] = 1, ['N'] = 1, ['O'] = 1, ['P'] = 1, ['Q'] = 1, ['R'] = 1,
251 ['S'] = 1, ['T'] = 1, ['U'] = 1, ['V'] = 1, ['W'] = 1, ['X'] = 1,
252 ['Y'] = 1, ['Z'] = 1,
253
254 ['_'] = 1,
255};
256
3fdc651f
ZW
257/* Table to tell if a character is horizontal space.
258 \r is magical, so it is not in here. */
6de1e2a9
ZW
259U_CHAR is_hor_space[256] =
260{
3fdc651f 261 [' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1,
6de1e2a9
ZW
262};
263/* table to tell if a character is horizontal or vertical space. */
264U_CHAR is_space[256] =
265{
3fdc651f 266 [' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1, ['\n'] = 1,
6de1e2a9 267};
5538ada6
ZW
268/* Table to handle trigraph conversion, which occurs before all other
269 processing, everywhere in the file. (This is necessary since one
270 of the trigraphs encodes backslash.) Note it's off by default.
271
272 from to from to from to
273 ?? = # ?? ) ] ?? ! |
274 ?? ( [ ?? ' ^ ?? > }
275 ?? / \ ?? < { ?? - ~
276
277 There is not a space between the ?? and the third char. I put spaces
278 there to avoid warnings when compiling this file. */
6de1e2a9
ZW
279U_CHAR trigraph_table[256] =
280{
281 ['='] = '#', [')'] = ']', ['!'] = '|',
282 ['('] = '[', ['\''] = '^', ['>'] = '}',
283 ['/'] = '\\', ['<'] = '{', ['-'] = '~',
284};
285
286/* This function will be entirely removed soon. */
287static inline void
288initialize_char_syntax (dollar_in_ident)
289 int dollar_in_ident;
290{
291 is_idchar['$'] = dollar_in_ident;
292 is_idstart['$'] = dollar_in_ident;
293}
294
295#else /* Not GCC. */
296
297U_CHAR is_idchar[256] = { 0 };
298U_CHAR is_idstart[256] = { 0 };
299U_CHAR is_hor_space[256] = { 0 };
300U_CHAR is_space[256] = { 0 };
5538ada6
ZW
301U_CHAR trigraph_table[256] = { 0 };
302
303/* Initialize syntactic classifications of characters. */
6de1e2a9 304static void
bdc1937e
KG
305initialize_char_syntax (dollar_in_ident)
306 int dollar_in_ident;
5538ada6
ZW
307{
308 is_idstart['a'] = 1; is_idstart['b'] = 1; is_idstart['c'] = 1;
309 is_idstart['d'] = 1; is_idstart['e'] = 1; is_idstart['f'] = 1;
310 is_idstart['g'] = 1; is_idstart['h'] = 1; is_idstart['i'] = 1;
311 is_idstart['j'] = 1; is_idstart['k'] = 1; is_idstart['l'] = 1;
312 is_idstart['m'] = 1; is_idstart['n'] = 1; is_idstart['o'] = 1;
313 is_idstart['p'] = 1; is_idstart['q'] = 1; is_idstart['r'] = 1;
314 is_idstart['s'] = 1; is_idstart['t'] = 1; is_idstart['u'] = 1;
315 is_idstart['v'] = 1; is_idstart['w'] = 1; is_idstart['x'] = 1;
316 is_idstart['y'] = 1; is_idstart['z'] = 1;
317
318 is_idstart['A'] = 1; is_idstart['B'] = 1; is_idstart['C'] = 1;
319 is_idstart['D'] = 1; is_idstart['E'] = 1; is_idstart['F'] = 1;
320 is_idstart['G'] = 1; is_idstart['H'] = 1; is_idstart['I'] = 1;
321 is_idstart['J'] = 1; is_idstart['K'] = 1; is_idstart['L'] = 1;
322 is_idstart['M'] = 1; is_idstart['N'] = 1; is_idstart['O'] = 1;
323 is_idstart['P'] = 1; is_idstart['Q'] = 1; is_idstart['R'] = 1;
324 is_idstart['S'] = 1; is_idstart['T'] = 1; is_idstart['U'] = 1;
325 is_idstart['V'] = 1; is_idstart['W'] = 1; is_idstart['X'] = 1;
326 is_idstart['Y'] = 1; is_idstart['Z'] = 1;
327
328 is_idstart['_'] = 1;
329
330 is_idchar['a'] = 1; is_idchar['b'] = 1; is_idchar['c'] = 1;
331 is_idchar['d'] = 1; is_idchar['e'] = 1; is_idchar['f'] = 1;
332 is_idchar['g'] = 1; is_idchar['h'] = 1; is_idchar['i'] = 1;
333 is_idchar['j'] = 1; is_idchar['k'] = 1; is_idchar['l'] = 1;
334 is_idchar['m'] = 1; is_idchar['n'] = 1; is_idchar['o'] = 1;
335 is_idchar['p'] = 1; is_idchar['q'] = 1; is_idchar['r'] = 1;
336 is_idchar['s'] = 1; is_idchar['t'] = 1; is_idchar['u'] = 1;
337 is_idchar['v'] = 1; is_idchar['w'] = 1; is_idchar['x'] = 1;
338 is_idchar['y'] = 1; is_idchar['z'] = 1;
339
340 is_idchar['A'] = 1; is_idchar['B'] = 1; is_idchar['C'] = 1;
341 is_idchar['D'] = 1; is_idchar['E'] = 1; is_idchar['F'] = 1;
342 is_idchar['G'] = 1; is_idchar['H'] = 1; is_idchar['I'] = 1;
343 is_idchar['J'] = 1; is_idchar['K'] = 1; is_idchar['L'] = 1;
344 is_idchar['M'] = 1; is_idchar['N'] = 1; is_idchar['O'] = 1;
345 is_idchar['P'] = 1; is_idchar['Q'] = 1; is_idchar['R'] = 1;
346 is_idchar['S'] = 1; is_idchar['T'] = 1; is_idchar['U'] = 1;
347 is_idchar['V'] = 1; is_idchar['W'] = 1; is_idchar['X'] = 1;
348 is_idchar['Y'] = 1; is_idchar['Z'] = 1;
349
350 is_idchar['1'] = 1; is_idchar['2'] = 1; is_idchar['3'] = 1;
351 is_idchar['4'] = 1; is_idchar['5'] = 1; is_idchar['6'] = 1;
352 is_idchar['7'] = 1; is_idchar['8'] = 1; is_idchar['9'] = 1;
353 is_idchar['0'] = 1;
354
355 is_idchar['_'] = 1;
356
5538ada6
ZW
357 is_idchar['$'] = dollar_in_ident;
358 is_idstart['$'] = dollar_in_ident;
359
6de1e2a9 360 /* white space tables */
5538ada6
ZW
361 is_hor_space[' '] = 1;
362 is_hor_space['\t'] = 1;
363 is_hor_space['\v'] = 1;
364 is_hor_space['\f'] = 1;
5538ada6
ZW
365
366 is_space[' '] = 1;
367 is_space['\t'] = 1;
368 is_space['\v'] = 1;
369 is_space['\f'] = 1;
370 is_space['\n'] = 1;
5538ada6
ZW
371
372 /* trigraph conversion */
373 trigraph_table['='] = '#'; trigraph_table[')'] = ']';
374 trigraph_table['!'] = '|'; trigraph_table['('] = '[';
375 trigraph_table['\''] = '^'; trigraph_table['>'] = '}';
376 trigraph_table['/'] = '\\'; trigraph_table['<'] = '{';
377 trigraph_table['-'] = '~';
378}
6de1e2a9
ZW
379
380#endif /* Not GCC. */
381
382/* Given a colon-separated list of file names PATH,
383 add all the names to the search path for include files. */
384
385static void
0b22d65c 386path_include (pfile, pend, list, path)
6de1e2a9 387 cpp_reader *pfile;
0b22d65c
ZW
388 struct cpp_pending *pend;
389 char *list;
390 int path;
6de1e2a9 391{
0b22d65c 392 char *p, *q, *name;
6de1e2a9 393
0b22d65c 394 p = list;
6de1e2a9 395
0b22d65c
ZW
396 do
397 {
6de1e2a9 398 /* Find the end of this name. */
0b22d65c 399 q = p;
6de1e2a9 400 while (*q != 0 && *q != PATH_SEPARATOR) q++;
0b22d65c
ZW
401 if (q == p)
402 {
403 /* An empty name in the path stands for the current directory. */
404 name = (char *) xmalloc (2);
405 name[0] = '.';
406 name[1] = 0;
407 }
408 else
409 {
410 /* Otherwise use the directory that is named. */
411 name = (char *) xmalloc (q - p + 1);
412 memcpy (name, p, q - p);
413 name[q - p] = 0;
414 }
6de1e2a9 415
0b22d65c 416 append_include_chain (pfile, pend, name, path);
6de1e2a9
ZW
417
418 /* Advance past this name. */
0b22d65c 419 if (*q == 0)
6de1e2a9 420 break;
0b22d65c
ZW
421 p = q + 1;
422 }
423 while (1);
424}
425
426/* Find the base name of a (partial) pathname FNAME.
427 Returns a pointer into the string passed in.
428 Accepts Unix (/-separated) paths on all systems,
429 DOS and VMS paths on those systems. */
430static char *
431base_name (fname)
432 const char *fname;
433{
434 char *s = (char *)fname;
435 char *p;
509781a4 436#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
0b22d65c
ZW
437 if (ISALPHA (s[0]) && s[1] == ':') s += 2;
438 if ((p = rindex (s, '\\'))) s = p + 1;
439#elif defined VMS
440 if ((p = rindex (s, ':'))) s = p + 1; /* Skip device. */
441 if ((p = rindex (s, ']'))) s = p + 1; /* Skip directory. */
442 if ((p = rindex (s, '>'))) s = p + 1; /* Skip alternate (int'n'l) dir. */
443#endif
444 if ((p = rindex (s, '/'))) s = p + 1;
445 return s;
446}
447
448
449/* Append DIR to include path PATH. DIR must be permanently allocated
450 and writable. */
451static void
452append_include_chain (pfile, pend, dir, path)
453 cpp_reader *pfile;
454 struct cpp_pending *pend;
455 char *dir;
456 int path;
457{
458 struct file_name_list *new;
459 struct stat st;
460 unsigned int len;
461
462 simplify_pathname (dir);
463 if (stat (dir, &st))
464 {
465 /* Dirs that don't exist are silently ignored. */
466 if (errno != ENOENT)
467 cpp_perror_with_name (pfile, dir);
468 else if (CPP_OPTIONS (pfile)->verbose)
469 cpp_notice ("ignoring nonexistent directory `%s'\n", dir);
470 return;
471 }
472
473 if (!S_ISDIR (st.st_mode))
474 {
475 cpp_message (pfile, 1, "%s: %s: Not a directory", progname, dir);
476 return;
477 }
478
479 len = strlen (dir);
480 if (len > pfile->max_include_len)
481 pfile->max_include_len = len;
482
483 new = (struct file_name_list *)xmalloc (sizeof (struct file_name_list));
484 new->name = dir;
485 new->nlen = len;
486 new->ino = st.st_ino;
487 new->dev = st.st_dev;
488 new->sysp = (path == SYSTEM);
489 new->name_map = NULL;
490
491 switch (path)
492 {
493 case QUOTE: APPEND (pend, quote, new); break;
494 case BRACKET: APPEND (pend, brack, new); break;
495 case SYSTEM: APPEND (pend, systm, new); break;
496 case AFTER: APPEND (pend, after, new); break;
6de1e2a9
ZW
497 }
498}
499
0b22d65c 500
6de1e2a9
ZW
501/* Write out a #define command for the special named MACRO_NAME
502 to PFILE's token_buffer. */
503
504static void
505dump_special_to_buffer (pfile, macro_name)
506 cpp_reader *pfile;
bcc5cac9 507 const char *macro_name;
6de1e2a9
ZW
508{
509 static char define_directive[] = "#define ";
510 int macro_name_length = strlen (macro_name);
80e9dcb4 511 output_line_command (pfile, same_file);
6de1e2a9
ZW
512 CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length);
513 CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1);
514 CPP_PUTS_Q (pfile, macro_name, macro_name_length);
515 CPP_PUTC_Q (pfile, ' ');
516 cpp_expand_to_buffer (pfile, macro_name, macro_name_length);
517 CPP_PUTC (pfile, '\n');
518}
519
6de1e2a9
ZW
520/* Initialize a cpp_options structure. */
521void
522cpp_options_init (opts)
523 cpp_options *opts;
524{
0b22d65c 525 bzero ((char *) opts, sizeof (struct cpp_options));
6de1e2a9
ZW
526
527 opts->dollars_in_ident = 1;
528 opts->cplusplus_comments = 1;
529 opts->warn_import = 1;
0b22d65c 530
ad85216e
KG
531 opts->pending =
532 (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
6de1e2a9
ZW
533}
534
535/* Initialize a cpp_reader structure. */
536void
537cpp_reader_init (pfile)
538 cpp_reader *pfile;
539{
540 bzero ((char *) pfile, sizeof (cpp_reader));
541#if 0
542 pfile->get_token = cpp_get_token;
543#endif
544
545 pfile->token_buffer_size = 200;
546 pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
547 CPP_SET_WRITTEN (pfile, 0);
122ae89b
ZW
548
549 pfile->hashtab = (HASHNODE **) xcalloc (HASHSIZE, sizeof (HASHNODE *));
6de1e2a9
ZW
550}
551
552/* Free resources used by PFILE.
553 This is the cpp_reader 'finalizer' or 'destructor' (in C++ terminology). */
554void
555cpp_cleanup (pfile)
556 cpp_reader *pfile;
557{
558 int i;
559 while (CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile))
560 cpp_pop_buffer (pfile);
561
562 if (pfile->token_buffer)
563 {
564 free (pfile->token_buffer);
565 pfile->token_buffer = NULL;
566 }
567
568 if (pfile->deps_buffer)
569 {
570 free (pfile->deps_buffer);
571 pfile->deps_buffer = NULL;
572 pfile->deps_allocated_size = 0;
573 }
574
2c826217
ZW
575 if (pfile->input_buffer)
576 {
577 free (pfile->input_buffer);
578 free (pfile->input_speccase);
579 pfile->input_buffer = pfile->input_speccase = NULL;
580 pfile->input_buffer_len = 0;
581 }
582
6de1e2a9
ZW
583 while (pfile->if_stack)
584 {
585 IF_STACK_FRAME *temp = pfile->if_stack;
586 pfile->if_stack = temp->next;
587 free (temp);
588 }
589
590 for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; )
591 {
592 struct include_hash *imp = pfile->all_include_files[i];
593 while (imp)
594 {
595 struct include_hash *next = imp->next;
596#if 0
597 /* This gets freed elsewhere - I think. */
598 free (imp->name);
599#endif
600 free (imp);
601 imp = next;
602 }
603 pfile->all_include_files[i] = 0;
604 }
605
122ae89b
ZW
606 for (i = HASHSIZE; --i >= 0;)
607 {
608 while (pfile->hashtab[i])
609 delete_macro (pfile->hashtab[i]);
610 }
611 free (pfile->hashtab);
6de1e2a9
ZW
612}
613
614
615/* Initialize the built-in macros. */
616static void
617initialize_builtins (pfile)
618 cpp_reader *pfile;
619{
bcc5cac9 620#define NAME(str) (const U_CHAR *)str, sizeof str - 1
122ae89b
ZW
621 cpp_install (pfile, NAME("__TIME__"), T_TIME, 0, -1);
622 cpp_install (pfile, NAME("__DATE__"), T_DATE, 0, -1);
623 cpp_install (pfile, NAME("__FILE__"), T_FILE, 0, -1);
624 cpp_install (pfile, NAME("__BASE_FILE__"), T_BASE_FILE, 0, -1);
625 cpp_install (pfile, NAME("__LINE__"), T_SPECLINE, 0, -1);
626 cpp_install (pfile, NAME("__INCLUDE_LEVEL__"), T_INCLUDE_LEVEL, 0, -1);
627 cpp_install (pfile, NAME("__VERSION__"), T_VERSION, 0, -1);
6de1e2a9 628#ifndef NO_BUILTIN_SIZE_TYPE
122ae89b 629 cpp_install (pfile, NAME("__SIZE_TYPE__"), T_CONST, SIZE_TYPE, -1);
6de1e2a9
ZW
630#endif
631#ifndef NO_BUILTIN_PTRDIFF_TYPE
122ae89b 632 cpp_install (pfile, NAME("__PTRDIFF_TYPE__ "), T_CONST, PTRDIFF_TYPE, -1);
6de1e2a9 633#endif
122ae89b
ZW
634 cpp_install (pfile, NAME("__WCHAR_TYPE__"), T_CONST, WCHAR_TYPE, -1);
635 cpp_install (pfile, NAME("__USER_LABEL_PREFIX__"), T_CONST, user_label_prefix, -1);
636 cpp_install (pfile, NAME("__REGISTER_PREFIX__"), T_CONST, REGISTER_PREFIX, -1);
507df939 637 cpp_install (pfile, NAME("__HAVE_BUILTIN_SETJMP__"), T_CONST, "1", -1);
6de1e2a9
ZW
638 if (!CPP_TRADITIONAL (pfile))
639 {
122ae89b 640 cpp_install (pfile, NAME("__STDC__"), T_STDC, 0, -1);
6de1e2a9
ZW
641#if 0
642 if (CPP_OPTIONS (pfile)->c9x)
122ae89b 643 cpp_install (pfile, NAME("__STDC_VERSION__"),T_CONST, "199909L", -1);
6de1e2a9
ZW
644 else
645#endif
122ae89b 646 cpp_install (pfile, NAME("__STDC_VERSION__"),T_CONST, "199409L", -1);
6de1e2a9
ZW
647 }
648#undef NAME
649
650 if (CPP_OPTIONS (pfile)->debug_output)
651 {
652 dump_special_to_buffer (pfile, "__BASE_FILE__");
653 dump_special_to_buffer (pfile, "__VERSION__");
654#ifndef NO_BUILTIN_SIZE_TYPE
655 dump_special_to_buffer (pfile, "__SIZE_TYPE__");
656#endif
657#ifndef NO_BUILTIN_PTRDIFF_TYPE
658 dump_special_to_buffer (pfile, "__PTRDIFF_TYPE__");
659#endif
660 dump_special_to_buffer (pfile, "__WCHAR_TYPE__");
661 dump_special_to_buffer (pfile, "__DATE__");
662 dump_special_to_buffer (pfile, "__TIME__");
663 if (!CPP_TRADITIONAL (pfile))
664 dump_special_to_buffer (pfile, "__STDC__");
665 }
666}
667
0b22d65c
ZW
668/* Another subroutine of cpp_start_read. This one sets up to do
669 dependency-file output. */
670static void
671initialize_dependency_output (pfile)
672 cpp_reader *pfile;
673{
674 cpp_options *opts = CPP_OPTIONS (pfile);
675 char *spec, *s, *output_file;
676
677 /* Either of two environment variables can specify output of deps.
678 Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
679 where OUTPUT_FILE is the file to write deps info to
680 and DEPS_TARGET is the target to mention in the deps. */
681
682 if (opts->print_deps == 0)
683 {
684 spec = getenv ("DEPENDENCIES_OUTPUT");
685 if (spec)
686 opts->print_deps = 1;
687 else
688 {
689 spec = getenv ("SUNPRO_DEPENDENCIES");
690 if (spec)
691 opts->print_deps = 2;
692 else
693 return;
694 }
695
696 /* Find the space before the DEPS_TARGET, if there is one. */
697 s = strchr (spec, ' ');
698 if (s)
699 {
700 opts->deps_target = s + 1;
701 output_file = (char *) xmalloc (s - spec + 1);
702 memcpy (output_file, spec, s - spec);
703 output_file[s - spec] = 0;
704 }
705 else
706 {
707 opts->deps_target = 0;
708 output_file = spec;
709 }
710
711 opts->deps_file = output_file;
712 opts->print_deps_append = 1;
713 }
714
715 /* Print the expected object file name as the target of this Make-rule. */
716 pfile->deps_allocated_size = 200;
717 pfile->deps_buffer = (char *) xmalloc (pfile->deps_allocated_size);
718 pfile->deps_buffer[0] = 0;
719 pfile->deps_size = 0;
720 pfile->deps_column = 0;
721
722 if (opts->deps_target)
723 deps_output (pfile, opts->deps_target, ':');
724 else if (*opts->in_fname == 0)
725 deps_output (pfile, "-", ':');
726 else
727 {
728 char *p, *q, *r;
729 int len, x;
730
731 /* Discard all directory prefixes from filename. */
732 q = base_name (opts->in_fname);
733
734 /* Copy remainder to mungable area. */
735 len = strlen (q);
736 p = (char *) alloca (len + 8);
737 strcpy (p, q);
738
739 /* Output P, but remove known suffixes. */
740 q = p + len;
741 /* Point to the filename suffix. */
742 r = rindex (p, '.');
743 /* Compare against the known suffixes. */
744 for (x = 0; known_suffixes[x]; x++)
745 {
746 if (strncmp (known_suffixes[x], r, q - r) == 0)
747 {
748 /* Make q point to the bit we're going to overwrite
749 with an object suffix. */
750 q = r;
751 break;
752 }
753 }
754
755 /* Supply our own suffix. */
756 strcpy (q, OBJECT_SUFFIX);
757
758 deps_output (pfile, p, ':');
759 deps_output (pfile, opts->in_fname, ' ');
760 }
761}
762
6de1e2a9
ZW
763/* This is called after options have been processed.
764 * Check options for consistency, and setup for processing input
765 * from the file named FNAME. (Use standard input if FNAME==NULL.)
766 * Return 1 on success, 0 on failure.
767 */
768
769int
770cpp_start_read (pfile, fname)
771 cpp_reader *pfile;
772 char *fname;
773{
774 struct cpp_options *opts = CPP_OPTIONS (pfile);
0b22d65c 775 struct pending_option *p, *q;
6de1e2a9
ZW
776 int f;
777 cpp_buffer *fp;
778 struct include_hash *ih_fake;
779
0b22d65c
ZW
780 /* -MG doesn't select the form of output and must be specified with one of
781 -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't
782 inhibit compilation. */
783 if (opts->print_deps_missing_files
784 && (opts->print_deps == 0 || !opts->no_output))
785 {
786 cpp_fatal (pfile, "-MG must be specified with one of -M or -MM");
787 return 0;
788 }
6de1e2a9 789
0b22d65c
ZW
790 /* Chill should not be used with -trigraphs. */
791 if (opts->chill && opts->trigraphs)
792 {
793 cpp_warning (pfile, "-lang-chill and -trigraphs are mutually exclusive");
794 opts->trigraphs = 0;
795 }
796
797 /* Set this if it hasn't been set already. */
798 if (user_label_prefix == NULL)
799 user_label_prefix = USER_LABEL_PREFIX;
800
6de1e2a9
ZW
801 /* Now that we know dollars_in_ident, we can initialize the syntax
802 tables. */
803 initialize_char_syntax (opts->dollars_in_ident);
6de1e2a9
ZW
804
805 /* Do partial setup of input buffer for the sake of generating
806 early #line directives (when -g is in effect). */
807 fp = cpp_push_buffer (pfile, NULL, 0);
808 if (!fp)
809 return 0;
810 if (opts->in_fname == NULL || *opts->in_fname == 0)
811 {
812 opts->in_fname = fname;
813 if (opts->in_fname == NULL)
814 opts->in_fname = "";
815 }
816 fp->nominal_fname = fp->fname = opts->in_fname;
817 fp->lineno = 0;
818
819 /* Install __LINE__, etc. Must follow initialize_char_syntax
820 and option processing. */
821 initialize_builtins (pfile);
822
6de1e2a9 823 /* Do -U's, -D's and -A's in the order they were seen. */
0b22d65c
ZW
824 p = opts->pending->define_head;
825 while (p)
6de1e2a9 826 {
0b22d65c 827 if (opts->debug_output)
80e9dcb4 828 output_line_command (pfile, same_file);
0b22d65c
ZW
829 if (p->undef)
830 cpp_undef (pfile, p->arg);
831 else
832 cpp_define (pfile, p->arg);
6de1e2a9 833
0b22d65c
ZW
834 q = p->next;
835 free (p);
836 p = q;
6de1e2a9 837 }
6de1e2a9 838
0b22d65c
ZW
839 p = opts->pending->assert_head;
840 while (p)
6de1e2a9 841 {
0b22d65c 842 if (opts->debug_output)
80e9dcb4 843 output_line_command (pfile, same_file);
0b22d65c
ZW
844 if (p->undef)
845 cpp_unassert (pfile, p->arg);
846 else
847 cpp_assert (pfile, p->arg);
6de1e2a9 848
0b22d65c
ZW
849 q = p->next;
850 free (p);
851 p = q;
852 }
853
854 opts->done_initializing = 1;
6de1e2a9 855
0b22d65c
ZW
856 /* Several environment variables may add to the include search path.
857 CPATH specifies an additional list of directories to be searched
858 as if specified with -I, while C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
859 etc. specify an additional list of directories to be searched as
860 if specified with -isystem, for the language indicated.
6de1e2a9 861
0b22d65c
ZW
862 These variables are ignored if -nostdinc is on. */
863 if (! opts->no_standard_includes)
864 {
865 char *path;
866 GET_ENV_PATH_LIST (path, "CPATH");
867 if (path != 0 && *path != 0)
868 path_include (pfile, opts->pending, path, BRACKET);
6de1e2a9 869
0b22d65c
ZW
870 switch ((opts->objc << 1) + opts->cplusplus)
871 {
872 case 0:
873 GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
874 break;
875 case 1:
876 GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
877 break;
878 case 2:
879 GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
880 break;
881 case 3:
882 GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
883 break;
884 }
885 if (path != 0 && *path != 0)
886 path_include (pfile, opts->pending, path, SYSTEM);
887 }
6de1e2a9 888
0b22d65c
ZW
889 /* Unless -nostdinc, add the compiled-in include path to the list,
890 translating prefixes. */
891 if (!opts->no_standard_includes)
6de1e2a9 892 {
0b22d65c
ZW
893 struct default_include *p = include_defaults_array;
894 char *specd_prefix = opts->include_prefix;
0b22d65c
ZW
895
896 /* Search "translated" versions of GNU directories.
897 These have /usr/local/lib/gcc... replaced by specd_prefix. */
898 if (specd_prefix != 0)
6de1e2a9 899 {
9e934a98 900 char *default_prefix = alloca (sizeof GCC_INCLUDE_DIR - 7);
0b22d65c
ZW
901 /* Remove the `include' from /usr/local/lib/gcc.../include.
902 GCC_INCLUDE_DIR will always end in /include. */
9e934a98
DB
903 int default_len = sizeof GCC_INCLUDE_DIR - 8;
904 int specd_len = strlen (specd_prefix);
905
0b22d65c
ZW
906 default_len = sizeof GCC_INCLUDE_DIR - 8;
907 memcpy (default_prefix, GCC_INCLUDE_DIR, default_len);
908 default_prefix[default_len] = '\0';
909
0b22d65c 910 for (p = include_defaults_array; p->fname; p++)
6de1e2a9 911 {
0b22d65c
ZW
912 /* Some standard dirs are only for C++. */
913 if (!p->cplusplus
914 || (opts->cplusplus
915 && !opts->no_standard_cplusplus_includes))
6de1e2a9 916 {
0b22d65c
ZW
917 /* Does this dir start with the prefix? */
918 if (!strncmp (p->fname, default_prefix, default_len))
919 {
920 /* Yes; change prefix and add to search list. */
921 int flen = strlen (p->fname);
9e934a98 922 int this_len = specd_len + flen - default_len;
0b22d65c
ZW
923 char *str = (char *) xmalloc (this_len + 1);
924 memcpy (str, specd_prefix, specd_len);
9e934a98
DB
925 memcpy (str + specd_len,
926 p->fname + default_len,
927 flen - default_len + 1);
0b22d65c
ZW
928
929 append_include_chain (pfile, opts->pending,
930 str, SYSTEM);
931 }
6de1e2a9 932 }
6de1e2a9 933 }
0b22d65c 934 }
6de1e2a9 935
0b22d65c
ZW
936 /* Search ordinary names for GNU include directories. */
937 for (p = include_defaults_array; p->fname; p++)
938 {
939 /* Some standard dirs are only for C++. */
940 if (!p->cplusplus
941 || (opts->cplusplus
942 && !opts->no_standard_cplusplus_includes))
943 {
bcc5cac9
KG
944 /* XXX Potential memory leak! */
945 char *str = xstrdup (update_path (p->fname, p->component));
0b22d65c
ZW
946 append_include_chain (pfile, opts->pending, str, SYSTEM);
947 }
948 }
949 }
6de1e2a9 950
0b22d65c
ZW
951 merge_include_chains (opts);
952
953 /* With -v, print the list of dirs to search. */
954 if (opts->verbose)
955 {
956 struct file_name_list *p;
957 cpp_message (pfile, -1, "#include \"...\" search starts here:\n");
958 for (p = opts->quote_include; p; p = p->next)
959 {
960 if (p == opts->bracket_include)
961 cpp_message (pfile, -1, "#include <...> search starts here:\n");
962 fprintf (stderr, " %s\n", p->name);
6de1e2a9 963 }
0b22d65c 964 cpp_message (pfile, -1, "End of search list.\n");
6de1e2a9
ZW
965 }
966
3773a46b
JM
967 /* Don't bother trying to do macro expansion if we've already done
968 preprocessing. */
969 if (opts->preprocessed)
970 pfile->no_macro_expand++;
971
0b22d65c
ZW
972 /* Open the main input file.
973 We do this in nonblocking mode so we don't get stuck here if
974 someone clever has asked cpp to process /dev/rmt0;
975 finclude() will check that we have a real file to work with. */
976 if (fname == NULL || *fname == 0)
977 {
978 fname = "";
979 f = 0;
980 }
981 else if ((f = open (fname, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666)) < 0)
982 cpp_pfatal_with_name (pfile, fname);
983
984 initialize_dependency_output (pfile);
985
6de1e2a9
ZW
986 /* Must call finclude() on the main input before processing
987 -include switches; otherwise the -included text winds up
988 after the main input. */
989 ih_fake = (struct include_hash *) xmalloc (sizeof (struct include_hash));
990 ih_fake->next = 0;
991 ih_fake->next_this_file = 0;
992 ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */
993 ih_fake->name = fname;
994 ih_fake->control_macro = 0;
995 ih_fake->buf = (char *)-1;
996 ih_fake->limit = 0;
997 if (!finclude (pfile, f, ih_fake))
998 return 0;
3773a46b
JM
999 if (opts->preprocessed)
1000 /* If we've already processed this code, we want to trust the #line
1001 directives in the input. But we still need to update our line
1002 counter accordingly. */
1003 pfile->lineno = CPP_BUFFER (pfile)->lineno;
1004 else
1005 output_line_command (pfile, same_file);
6de1e2a9
ZW
1006 pfile->only_seen_white = 2;
1007
1008 /* The -imacros files can be scanned now, but the -include files
1009 have to be pushed onto the include stack and processed later,
0b22d65c 1010 in the main loop calling cpp_get_token. */
6de1e2a9
ZW
1011
1012 pfile->no_record_file++;
1013 opts->no_output++;
0b22d65c
ZW
1014 p = opts->pending->imacros_head;
1015 while (p)
6de1e2a9 1016 {
0b22d65c
ZW
1017 int fd = open (p->arg, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666);
1018 if (fd < 0)
1019 {
1020 cpp_perror_with_name (pfile, p->arg);
1021 return 0;
6de1e2a9 1022 }
0b22d65c
ZW
1023 if (!cpp_push_buffer (pfile, NULL, 0))
1024 return 0;
1025
1026 ih_fake = (struct include_hash *)
1027 xmalloc (sizeof (struct include_hash));
1028 ih_fake->next = 0;
1029 ih_fake->next_this_file = 0;
1030 ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */
1031 ih_fake->name = p->arg;
1032 ih_fake->control_macro = 0;
1033 ih_fake->buf = (char *)-1;
1034 ih_fake->limit = 0;
5d83f44b
ZW
1035 if (finclude (pfile, fd, ih_fake))
1036 {
1037 if (CPP_PRINT_DEPS (pfile))
1038 deps_output (pfile, ih_fake->name, ' ');
1039
1040 cpp_scan_buffer (pfile);
1041 }
1042 else
1043 cpp_pop_buffer (pfile);
0b22d65c
ZW
1044 free (ih_fake);
1045
1046 q = p->next;
1047 free (p);
1048 p = q;
6de1e2a9 1049 }
0b22d65c 1050
6de1e2a9 1051 opts->no_output--;
0b22d65c
ZW
1052
1053 p = opts->pending->include_head;
1054 while (p)
6de1e2a9 1055 {
0b22d65c
ZW
1056 int fd = open (p->arg, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666);
1057 if (fd < 0)
1058 {
1059 cpp_perror_with_name (pfile, p->arg);
1060 return 0;
6de1e2a9 1061 }
0b22d65c
ZW
1062 if (!cpp_push_buffer (pfile, NULL, 0))
1063 return 0;
1064
1065 ih_fake = (struct include_hash *)
1066 xmalloc (sizeof (struct include_hash));
1067 ih_fake->next = 0;
1068 ih_fake->next_this_file = 0;
1069 ih_fake->foundhere = ABSOLUTE_PATH; /* well sort of ... */
1070 ih_fake->name = p->arg;
1071 ih_fake->control_macro = 0;
1072 ih_fake->buf = (char *)-1;
1073 ih_fake->limit = 0;
1074 if (finclude (pfile, fd, ih_fake))
5d83f44b
ZW
1075 {
1076 if (CPP_PRINT_DEPS (pfile))
1077 deps_output (pfile, ih_fake->name, ' ');
1078
1079 output_line_command (pfile, enter_file);
1080 }
1081 else
1082 cpp_pop_buffer (pfile);
0b22d65c
ZW
1083 q = p->next;
1084 free (p);
1085 p = q;
6de1e2a9
ZW
1086 }
1087 pfile->no_record_file--;
1088
0b22d65c 1089 free (opts->pending);
6de1e2a9
ZW
1090 opts->pending = NULL;
1091
1092 return 1;
1093}
1094
1095/* This is called at the end of preprocessing. It pops the
1096 last buffer and writes dependency output. It should also
1097 clear macro definitions, such that you could call cpp_start_read
1098 with a new filename to restart processing. */
1099void
1100cpp_finish (pfile)
1101 cpp_reader *pfile;
1102{
1103 struct cpp_options *opts = CPP_OPTIONS (pfile);
1104
1105 if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != CPP_NULL_BUFFER (pfile))
1106 cpp_fatal (pfile,
1107 "cpplib internal error: buffers still stacked in cpp_finish");
1108 cpp_pop_buffer (pfile);
1109
1110 if (opts->print_deps)
1111 {
1112 /* Stream on which to print the dependency information. */
1113 FILE *deps_stream;
1114
1115 /* Don't actually write the deps file if compilation has failed. */
1116 if (pfile->errors == 0)
1117 {
bcc5cac9 1118 const char *deps_mode = opts->print_deps_append ? "a" : "w";
6de1e2a9
ZW
1119 if (opts->deps_file == 0)
1120 deps_stream = stdout;
1121 else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0)
1122 cpp_pfatal_with_name (pfile, opts->deps_file);
1123 fputs (pfile->deps_buffer, deps_stream);
1124 putc ('\n', deps_stream);
1125 if (opts->deps_file)
1126 {
1127 if (ferror (deps_stream) || fclose (deps_stream) != 0)
1128 cpp_fatal (pfile, "I/O error on output");
1129 }
1130 }
1131 }
3caee4a8
ZW
1132
1133 if (opts->dump_macros == dump_only)
1134 {
1135 int i;
1136 HASHNODE *h;
1137 MACRODEF m;
1138 for (i = HASHSIZE; --i >= 0;)
1139 {
1140 for (h = pfile->hashtab[i]; h; h = h->next)
1141 if (h->type == T_MACRO)
1142 {
1143 m.defn = h->value.defn;
1144 m.symnam = h->name;
1145 m.symlen = h->length;
1146 dump_definition (pfile, m);
1147 CPP_PUTC (pfile, '\n');
1148 }
1149 }
1150 }
6de1e2a9
ZW
1151}
1152
1153/* Handle one command-line option in (argc, argv).
1154 Can be called multiple times, to handle multiple sets of options.
1155 Returns number of strings consumed. */
1156int
1157cpp_handle_option (pfile, argc, argv)
1158 cpp_reader *pfile;
1159 int argc;
1160 char **argv;
1161{
1162 struct cpp_options *opts = CPP_OPTIONS (pfile);
1163 int i = 0;
1164
0b22d65c
ZW
1165 if (argv[i][0] != '-')
1166 {
1167 if (opts->out_fname != NULL)
6de1e2a9 1168 {
0b22d65c
ZW
1169 print_help ();
1170 cpp_fatal (pfile, "Too many arguments");
6de1e2a9 1171 }
0b22d65c
ZW
1172 else if (opts->in_fname != NULL)
1173 opts->out_fname = argv[i];
1174 else
1175 opts->in_fname = argv[i];
1176 }
1177 else
1178 switch (argv[i][1])
1179 {
1180 case 'f':
1181 if (!strcmp (argv[i], "-fleading-underscore"))
1182 user_label_prefix = "_";
1183 else if (!strcmp (argv[i], "-fno-leading-underscore"))
1184 user_label_prefix = "";
3773a46b
JM
1185 else if (!strcmp (argv[i], "-fpreprocessed"))
1186 opts->preprocessed = 1;
1187 else if (!strcmp (argv[i], "-fno-preprocessed"))
1188 opts->preprocessed = 0;
0b22d65c
ZW
1189 break;
1190
1191 case 'I': /* Add directory to path for includes. */
1192 if (!strcmp (argv[i] + 2, "-"))
1193 {
1194 /* -I- means:
1195 Use the preceding -I directories for #include "..."
1196 but not #include <...>.
1197 Don't search the directory of the present file
1198 for #include "...". (Note that -I. -I- is not the same as
1199 the default setup; -I. uses the compiler's working dir.) */
1200 if (! opts->ignore_srcdir)
1201 {
1202 opts->ignore_srcdir = 1;
1203 opts->pending->quote_head = opts->pending->brack_head;
1204 opts->pending->quote_tail = opts->pending->brack_tail;
1205 opts->pending->brack_head = 0;
1206 opts->pending->brack_tail = 0;
1207 }
1208 else
1209 {
1210 cpp_fatal (pfile, "-I- specified twice");
1211 return argc;
1212 }
1213 }
1214 else
1215 {
1216 char *fname;
1217 if (argv[i][2] != 0)
1218 fname = argv[i] + 2;
1219 else if (i + 1 == argc)
1220 goto missing_dirname;
1221 else
1222 fname = argv[++i];
1223 append_include_chain (pfile, opts->pending,
1224 xstrdup (fname), BRACKET);
1225 }
1226 break;
1227
1228 case 'i':
1229 /* Add directory to beginning of system include path, as a system
1230 include directory. */
1231 if (!strcmp (argv[i], "-isystem"))
1232 {
1233 if (i + 1 == argc)
1234 goto missing_filename;
1235 append_include_chain (pfile, opts->pending,
1236 xstrdup (argv[++i]), SYSTEM);
1237 }
1238 else if (!strcmp (argv[i], "-include"))
1239 {
1240 if (i + 1 == argc)
1241 goto missing_filename;
1242 else
1243 {
1244 struct pending_option *o = (struct pending_option *)
1245 xmalloc (sizeof (struct pending_option));
1246 o->arg = argv[++i];
1247
1248 /* This list has to be built in reverse order so that
1249 when cpp_start_read pushes all the -include files onto
1250 the buffer stack, they will be scanned in forward order. */
1251 o->next = opts->pending->include_head;
1252 opts->pending->include_head = o;
1253 }
1254 }
1255 else if (!strcmp (argv[i], "-imacros"))
1256 {
1257 if (i + 1 == argc)
1258 goto missing_filename;
1259 else
1260 {
1261 struct pending_option *o = (struct pending_option *)
1262 xmalloc (sizeof (struct pending_option));
1263 o->arg = argv[++i];
1264 o->next = NULL;
1265
1266 APPEND (opts->pending, imacros, o);
1267 }
1268 }
1269 /* Add directory to end of path for includes,
1270 with the default prefix at the front of its name. */
1271 else if (!strcmp (argv[i], "-iwithprefix"))
1272 {
1273 char *fname;
1274 int len;
1275 if (i + 1 == argc)
1276 goto missing_dirname;
1277 ++i;
1278 len = strlen (argv[i]);
1279
1280 if (opts->include_prefix != 0)
1281 {
1282 fname = xmalloc (opts->include_prefix_len + len + 1);
1283 memcpy (fname, opts->include_prefix, opts->include_prefix_len);
1284 memcpy (fname + opts->include_prefix_len, argv[i], len + 1);
1285 }
1286 else
1287 {
1288 fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
1289 memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
1290 memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1);
1291 }
6de1e2a9 1292
0b22d65c
ZW
1293 append_include_chain (pfile, opts->pending, fname, SYSTEM);
1294 }
1295 /* Add directory to main path for includes,
1296 with the default prefix at the front of its name. */
1297 else if (!strcmp (argv[i], "-iwithprefixbefore"))
1298 {
1299 char *fname;
1300 int len;
1301 if (i + 1 == argc)
1302 goto missing_dirname;
1303 ++i;
1304 len = strlen (argv[i]);
1305
1306 if (opts->include_prefix != 0)
1307 {
1308 fname = xmalloc (opts->include_prefix_len + len + 1);
1309 memcpy (fname, opts->include_prefix, opts->include_prefix_len);
1310 memcpy (fname + opts->include_prefix_len, argv[i], len + 1);
1311 }
1312 else
1313 {
1314 fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
1315 memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
1316 memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, argv[i], len + 1);
1317 }
6de1e2a9 1318
0b22d65c
ZW
1319 append_include_chain (pfile, opts->pending, fname, BRACKET);
1320 }
1321 /* Add directory to end of path for includes. */
1322 else if (!strcmp (argv[i], "-idirafter"))
1323 {
1324 if (i + 1 == argc)
1325 goto missing_dirname;
1326 append_include_chain (pfile, opts->pending,
1327 xstrdup (argv[++i]), AFTER);
1328 }
1329 else if (!strcmp (argv[i], "-iprefix"))
1330 {
1331 if (i + 1 == argc)
1332 goto missing_filename;
1333 else
1334 {
1335 opts->include_prefix = argv[++i];
1336 opts->include_prefix_len = strlen (argv[i]);
1337 }
1338 }
1339 else if (!strcmp (argv[i], "-ifoutput"))
1340 opts->output_conditionals = 1;
6de1e2a9 1341
0b22d65c 1342 break;
6de1e2a9 1343
0b22d65c
ZW
1344 case 'o':
1345 if (opts->out_fname != NULL)
1346 {
1347 cpp_fatal (pfile, "Output filename specified twice");
1348 return argc;
1349 }
1350 if (i + 1 == argc)
1351 goto missing_filename;
1352 opts->out_fname = argv[++i];
1353 if (!strcmp (opts->out_fname, "-"))
1354 opts->out_fname = "";
1355 break;
6de1e2a9 1356
0b22d65c
ZW
1357 case 'p':
1358 if (!strcmp (argv[i], "-pedantic"))
1359 CPP_PEDANTIC (pfile) = 1;
1360 else if (!strcmp (argv[i], "-pedantic-errors"))
1361 {
1362 CPP_PEDANTIC (pfile) = 1;
1363 opts->pedantic_errors = 1;
1364 }
6de1e2a9 1365#if 0
0b22d65c
ZW
1366 else if (!strcmp (argv[i], "-pcp")) {
1367 char *pcp_fname = argv[++i];
1368 pcp_outfile = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0')
1369 ? fopen (pcp_fname, "w")
1370 : fdopen (dup (fileno (stdout)), "w"));
1371 if (pcp_outfile == 0)
1372 cpp_pfatal_with_name (pfile, pcp_fname);
1373 no_precomp = 1;
1374 }
6de1e2a9 1375#endif
0b22d65c 1376 break;
6de1e2a9 1377
0b22d65c
ZW
1378 case 't':
1379 if (!strcmp (argv[i], "-traditional"))
1380 {
1381 opts->traditional = 1;
1382 opts->cplusplus_comments = 0;
1383 }
1384 else if (!strcmp (argv[i], "-trigraphs"))
6de1e2a9 1385 opts->trigraphs = 1;
0b22d65c 1386 break;
6de1e2a9 1387
0b22d65c
ZW
1388 case 'l':
1389 if (! strcmp (argv[i], "-lang-c"))
1390 opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
1391 opts->c9x = 1, opts->objc = 0;
1392 if (! strcmp (argv[i], "-lang-c89"))
1393 opts->cplusplus = 0, opts->cplusplus_comments = 0, opts->c89 = 1,
1394 opts->c9x = 0, opts->objc = 0;
1395 if (! strcmp (argv[i], "-lang-c++"))
1396 opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0,
1397 opts->c9x = 0, opts->objc = 0;
1398 if (! strcmp (argv[i], "-lang-objc"))
1399 opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
1400 opts->c9x = 0, opts->objc = 1;
1401 if (! strcmp (argv[i], "-lang-objc++"))
1402 opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0,
1403 opts->c9x = 0, opts->objc = 1;
1404 if (! strcmp (argv[i], "-lang-asm"))
1405 opts->lang_asm = 1;
1406 if (! strcmp (argv[i], "-lint"))
1407 opts->for_lint = 1;
1408 if (! strcmp (argv[i], "-lang-chill"))
1409 opts->objc = 0, opts->cplusplus = 0, opts->chill = 1,
1410 opts->traditional = 1;
1411 break;
6de1e2a9 1412
0b22d65c
ZW
1413 case '+':
1414 opts->cplusplus = 1, opts->cplusplus_comments = 1;
1415 break;
1416
1417 case 's':
1418 if (!strcmp (argv[i], "-std=iso9899:1990")
1419 || !strcmp (argv[i], "-std=iso9899:199409")
1420 || !strcmp (argv[i], "-std=c89")
1421 || !strcmp (argv[i], "-std=gnu89"))
6de1e2a9
ZW
1422 opts->cplusplus = 0, opts->cplusplus_comments = 0,
1423 opts->c89 = 1, opts->c9x = 0, opts->objc = 0;
0b22d65c
ZW
1424 else if (!strcmp (argv[i], "-std=iso9899:199x")
1425 || !strcmp (argv[i], "-std=c9x")
1426 || !strcmp (argv[i], "-std=gnu9x"))
1427 opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
1428 opts->c9x = 1, opts->objc = 0;
1429 break;
1430
1431 case 'w':
1432 opts->inhibit_warnings = 1;
1433 break;
6de1e2a9 1434
0b22d65c
ZW
1435 case 'W':
1436 if (!strcmp (argv[i], "-Wtrigraphs"))
6de1e2a9 1437 opts->warn_trigraphs = 1;
0b22d65c
ZW
1438 else if (!strcmp (argv[i], "-Wno-trigraphs"))
1439 opts->warn_trigraphs = 0;
1440 else if (!strcmp (argv[i], "-Wcomment"))
6de1e2a9 1441 opts->warn_comments = 1;
0b22d65c
ZW
1442 else if (!strcmp (argv[i], "-Wno-comment"))
1443 opts->warn_comments = 0;
1444 else if (!strcmp (argv[i], "-Wcomments"))
1445 opts->warn_comments = 1;
1446 else if (!strcmp (argv[i], "-Wno-comments"))
1447 opts->warn_comments = 0;
1448 else if (!strcmp (argv[i], "-Wtraditional"))
1449 opts->warn_stringify = 1;
1450 else if (!strcmp (argv[i], "-Wno-traditional"))
1451 opts->warn_stringify = 0;
1452 else if (!strcmp (argv[i], "-Wundef"))
1453 opts->warn_undef = 1;
1454 else if (!strcmp (argv[i], "-Wno-undef"))
1455 opts->warn_undef = 0;
1456 else if (!strcmp (argv[i], "-Wimport"))
1457 opts->warn_import = 1;
1458 else if (!strcmp (argv[i], "-Wno-import"))
1459 opts->warn_import = 0;
1460 else if (!strcmp (argv[i], "-Werror"))
1461 opts->warnings_are_errors = 1;
1462 else if (!strcmp (argv[i], "-Wno-error"))
1463 opts->warnings_are_errors = 0;
1464 else if (!strcmp (argv[i], "-Wall"))
1465 {
1466 opts->warn_trigraphs = 1;
1467 opts->warn_comments = 1;
1468 }
1469 break;
6de1e2a9 1470
0b22d65c
ZW
1471 case 'M':
1472 /* The style of the choices here is a bit mixed.
1473 The chosen scheme is a hybrid of keeping all options in one string
1474 and specifying each option in a separate argument:
1475 -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
1476 -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
1477 -M[M][G][D file]. This is awkward to handle in specs, and is not
1478 as extensible. */
1479 /* ??? -MG must be specified in addition to one of -M or -MM.
1480 This can be relaxed in the future without breaking anything.
1481 The converse isn't true. */
6de1e2a9 1482
0b22d65c
ZW
1483 /* -MG isn't valid with -MD or -MMD. This is checked for later. */
1484 if (!strcmp (argv[i], "-MG"))
1485 {
1486 opts->print_deps_missing_files = 1;
6de1e2a9
ZW
1487 break;
1488 }
0b22d65c
ZW
1489 if (!strcmp (argv[i], "-M"))
1490 opts->print_deps = 2;
1491 else if (!strcmp (argv[i], "-MM"))
1492 opts->print_deps = 1;
1493 else if (!strcmp (argv[i], "-MD"))
1494 opts->print_deps = 2;
1495 else if (!strcmp (argv[i], "-MMD"))
1496 opts->print_deps = 1;
1497 /* For -MD and -MMD options, write deps on file named by next arg. */
1498 if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD"))
1499 {
1500 if (i+1 == argc)
1501 goto missing_filename;
1502 opts->deps_file = argv[++i];
1503 }
1504 else
1505 {
1506 /* For -M and -MM, write deps on standard output
1507 and suppress the usual output. */
1508 opts->no_output = 1;
1509 }
1510 break;
1511
1512 case 'd':
1513 {
1514 char *p = argv[i] + 2;
1515 char c;
1516 while ((c = *p++) != 0)
1517 {
1518 /* Arg to -d specifies what parts of macros to dump */
1519 switch (c)
1520 {
1521 case 'M':
1522 opts->dump_macros = dump_only;
1523 opts->no_output = 1;
1524 break;
1525 case 'N':
1526 opts->dump_macros = dump_names;
1527 break;
1528 case 'D':
1529 opts->dump_macros = dump_definitions;
1530 break;
1531 case 'I':
1532 opts->dump_includes = 1;
1533 break;
1534 }
1535 }
6de1e2a9 1536 }
0b22d65c 1537 break;
6de1e2a9 1538
0b22d65c
ZW
1539 case 'g':
1540 if (argv[i][2] == '3')
1541 opts->debug_output = 1;
1542 break;
6de1e2a9 1543
0b22d65c
ZW
1544 case '-':
1545 if (!strcmp (argv[i], "--help"))
1546 print_help ();
1547 else if (!strcmp (argv[i], "--version"))
1548 cpp_notice ("GNU CPP version %s\n", version_string);
1549 exit (0); /* XXX */
1550 break;
6de1e2a9 1551
0b22d65c
ZW
1552 case 'v':
1553 cpp_notice ("GNU CPP version %s", version_string);
6de1e2a9 1554#ifdef TARGET_VERSION
0b22d65c 1555 TARGET_VERSION;
6de1e2a9 1556#endif
0b22d65c
ZW
1557 fputc ('\n', stderr);
1558 opts->verbose = 1;
1559 break;
6de1e2a9 1560
0b22d65c
ZW
1561 case 'H':
1562 opts->print_include_names = 1;
1563 break;
6de1e2a9 1564
0b22d65c 1565 case 'D':
6de1e2a9 1566 {
0b22d65c
ZW
1567 struct pending_option *o = (struct pending_option *)
1568 xmalloc (sizeof (struct pending_option));
1569 if (argv[i][2] != 0)
1570 o->arg = argv[i] + 2;
1571 else if (i + 1 == argc)
1572 {
1573 cpp_fatal (pfile, "Macro name missing after -D option");
1574 return argc;
1575 }
1576 else
1577 o->arg = argv[++i];
1578
1579 o->next = NULL;
1580 o->undef = 0;
1581 APPEND (opts->pending, define, o);
6de1e2a9 1582 }
0b22d65c 1583 break;
6de1e2a9 1584
0b22d65c
ZW
1585 case 'A':
1586 {
1587 char *p;
6de1e2a9 1588
0b22d65c
ZW
1589 if (argv[i][2] != 0)
1590 p = argv[i] + 2;
1591 else if (i + 1 == argc)
1592 {
1593 cpp_fatal (pfile, "Assertion missing after -A option");
1594 return argc;
1595 }
1596 else
1597 p = argv[++i];
6de1e2a9 1598
0b22d65c 1599 if (strcmp (p, "-"))
6de1e2a9 1600 {
0b22d65c
ZW
1601 struct pending_option *o = (struct pending_option *)
1602 xmalloc (sizeof (struct pending_option));
1603
1604 o->arg = p;
1605 o->next = NULL;
1606 o->undef = 0;
1607 APPEND (opts->pending, assert, o);
1608 }
1609 else
1610 {
1611 /* -A- eliminates all predefined macros and assertions.
1612 Let's include also any that were specified earlier
1613 on the command line. That way we can get rid of any
1614 that were passed automatically in from GCC. */
1615 struct pending_option *o1, *o2;
1616
1617 o1 = opts->pending->define_head;
1618 while (o1)
1619 {
1620 o2 = o1->next;
1621 free (o1);
1622 o1 = o2;
1623 }
1624 o1 = opts->pending->assert_head;
1625 while (o1)
6de1e2a9 1626 {
0b22d65c
ZW
1627 o2 = o1->next;
1628 free (o1);
1629 o1 = o2;
6de1e2a9 1630 }
0b22d65c
ZW
1631 opts->pending->assert_head = NULL;
1632 opts->pending->assert_tail = NULL;
1633 opts->pending->define_head = NULL;
1634 opts->pending->define_tail = NULL;
6de1e2a9 1635 }
6de1e2a9 1636 }
0b22d65c 1637 break;
6de1e2a9 1638
0b22d65c 1639 case 'U':
6de1e2a9 1640 {
0b22d65c
ZW
1641 struct pending_option *o = (struct pending_option *)
1642 xmalloc (sizeof (struct pending_option));
1643
1644 if (argv[i][2] != 0)
1645 o->arg = argv[i] + 2;
1646 else if (i + 1 == argc)
1647 {
1648 cpp_fatal (pfile, "Macro name missing after -U option");
1649 return argc;
1650 }
1651 else
1652 o->arg = argv[++i];
1653
1654 o->next = NULL;
1655 o->undef = 1;
1656 APPEND (opts->pending, define, o);
6de1e2a9 1657 }
0b22d65c 1658 break;
6de1e2a9 1659
0b22d65c
ZW
1660 case 'C':
1661 opts->put_out_comments = 1;
1662 break;
6de1e2a9 1663
0b22d65c
ZW
1664 case 'E': /* -E comes from cc -E; ignore it. */
1665 break;
6de1e2a9 1666
0b22d65c
ZW
1667 case 'P':
1668 opts->no_line_commands = 1;
1669 break;
6de1e2a9 1670
0b22d65c
ZW
1671 case '$': /* Don't include $ in identifiers. */
1672 opts->dollars_in_ident = 0;
1673 break;
6de1e2a9 1674
0b22d65c
ZW
1675 case 'n':
1676 if (!strcmp (argv[i], "-nostdinc"))
1677 /* -nostdinc causes no default include directories.
1678 You must specify all include-file directories with -I. */
1679 opts->no_standard_includes = 1;
1680 else if (!strcmp (argv[i], "-nostdinc++"))
1681 /* -nostdinc++ causes no default C++-specific include directories. */
1682 opts->no_standard_cplusplus_includes = 1;
6de1e2a9 1683#if 0
0b22d65c
ZW
1684 else if (!strcmp (argv[i], "-noprecomp"))
1685 no_precomp = 1;
6de1e2a9 1686#endif
0b22d65c 1687 break;
6de1e2a9 1688
0b22d65c
ZW
1689 case 'r':
1690 if (!strcmp (argv[i], "-remap"))
1691 opts->remap = 1;
1692 break;
6de1e2a9 1693
0b22d65c
ZW
1694 case '\0': /* JF handle '-' as file name meaning stdin or stdout */
1695 if (opts->in_fname == NULL)
1696 opts->in_fname = "";
1697 else if (opts->out_fname == NULL)
1698 opts->out_fname = "";
1699 else
1700 return i; /* error */
6de1e2a9 1701 break;
6de1e2a9 1702
0b22d65c
ZW
1703 default:
1704 return i;
1705 }
6de1e2a9
ZW
1706
1707 return i + 1;
0b22d65c
ZW
1708
1709 missing_filename:
1710 cpp_fatal (pfile, "Filename missing after `%s' option", argv[i]);
1711 return argc;
1712 missing_dirname:
1713 cpp_fatal (pfile, "Directory name missing after `%s' option", argv[i]);
1714 return argc;
6de1e2a9
ZW
1715}
1716
1717/* Handle command-line options in (argc, argv).
1718 Can be called multiple times, to handle multiple sets of options.
1719 Returns if an unrecognized option is seen.
1720 Returns number of strings consumed. */
1721
1722int
1723cpp_handle_options (pfile, argc, argv)
1724 cpp_reader *pfile;
1725 int argc;
1726 char **argv;
1727{
1728 int i;
1729 int strings_processed;
1730 for (i = 0; i < argc; i += strings_processed)
1731 {
1732 strings_processed = cpp_handle_option (pfile, argc - i, argv + i);
1733 if (strings_processed == 0)
1734 break;
1735 }
1736 return i;
1737}
1738
1739static void
1740print_help ()
1741{
1742 cpp_notice ("Usage: %s [switches] input output\n", progname);
1743 fputs (_("\
1744Switches:\n\
1745 -include <file> Include the contents of <file> before other files\n\
1746 -imacros <file> Accept definition of macros in <file>\n\
1747 -iprefix <path> Specify <path> as a prefix for next two options\n\
1748 -iwithprefix <dir> Add <dir> to the end of the system include path\n\
1749 -iwithprefixbefore <dir> Add <dir> to the end of the main include path\n\
1750 -isystem <dir> Add <dir> to the start of the system include path\n\
1751 -idirafter <dir> Add <dir> to the end of the system include path\n\
1752 -I <dir> Add <dir> to the end of the main include path\n\
1753 -nostdinc Do not search system include directories\n\
1754 (dirs specified with -isystem will still be used)\n\
1755 -nostdinc++ Do not search system include directories for C++\n\
1756 -o <file> Put output into <file>\n\
1757 -pedantic Issue all warnings demanded by strict ANSI C\n\
1758 -traditional Follow K&R pre-processor behaviour\n\
1759 -trigraphs Support ANSI C trigraphs\n\
1760 -lang-c Assume that the input sources are in C\n\
1761 -lang-c89 Assume that the input sources are in C89\n\
1762 -lang-c++ Assume that the input sources are in C++\n\
1763 -lang-objc Assume that the input sources are in ObjectiveC\n\
1764 -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
1765 -lang-asm Assume that the input sources are in assembler\n\
1766 -lang-chill Assume that the input sources are in Chill\n\
1767 -std=<std name> Specify the conformance standard; one of:\n\
1768 gnu89, gnu9x, c89, c9x, iso9899:1990,\n\
1769 iso9899:199409, iso9899:199x\n\
6de1e2a9
ZW
1770 -+ Allow parsing of C++ style features\n\
1771 -w Inhibit warning messages\n\
1772 -Wtrigraphs Warn if trigraphs are encountered\n\
1773 -Wno-trigraphs Do not warn about trigraphs\n\
1774 -Wcomment{s} Warn if one comment starts inside another\n\
1775 -Wno-comment{s} Do not warn about comments\n\
1776 -Wtraditional Warn if a macro argument is/would be turned into\n\
1777 a string if -traditional is specified\n\
1778 -Wno-traditional Do not warn about stringification\n\
1779 -Wundef Warn if an undefined macro is used by #if\n\
1780 -Wno-undef Do not warn about testing undefined macros\n\
1781 -Wimport Warn about the use of the #import directive\n\
1782 -Wno-import Do not warn about the use of #import\n\
1783 -Werror Treat all warnings as errors\n\
1784 -Wno-error Do not treat warnings as errors\n\
1785 -Wall Enable all preprocessor warnings\n\
1786 -M Generate make dependencies\n\
1787 -MM As -M, but ignore system header files\n\
1788 -MD As -M, but put output in a .d file\n\
1789 -MMD As -MD, but ignore system header files\n\
1790 -MG Treat missing header file as generated files\n\
1791 -g Include #define and #undef directives in the output\n\
1792 -D<macro> Define a <macro> with string '1' as its value\n\
1793 -D<macro>=<val> Define a <macro> with <val> as its value\n\
1794 -A<question> (<answer>) Assert the <answer> to <question>\n\
1795 -U<macro> Undefine <macro> \n\
6de1e2a9
ZW
1796 -v Display the version number\n\
1797 -H Print the name of header files as they are used\n\
1798 -C Do not discard comments\n\
1799 -dM Display a list of macro definitions active at end\n\
1800 -dD Preserve macro definitions in output\n\
1801 -dN As -dD except that only the names are preserved\n\
1802 -dI Include #include directives in the output\n\
1803 -ifoutput Describe skipped code blocks in output \n\
1804 -P Do not generate #line directives\n\
1805 -$ Do not allow '$' in identifiers\n\
1806 -remap Remap file names when including files.\n\
1807 -h or --help Display this information\n\
1808"), stdout);
1809}
This page took 0.309735 seconds and 5 git commands to generate.