📄 cccp.c
字号:
char **pend_undefs = (char **) xmalloc (argc * sizeof (char *)); char **pend_assertions = (char **) xmalloc (argc * sizeof (char *)); char **pend_includes = (char **) xmalloc (argc * sizeof (char *)); /* Record the option used with each element of pend_assertions. This is preparation for supporting more than one option for making an assertion. */ char **pend_assertion_options = (char **) xmalloc (argc * sizeof (char *)); int inhibit_predefs = 0; int no_standard_includes = 0; int no_standard_cplusplus_includes = 0; int missing_newline = 0; /* Non-0 means don't output the preprocessed program. */ int inhibit_output = 0; /* Non-0 means -v, so print the full set of include dirs. */ int verbose = 0; /* File name which deps are being written to. This is 0 if deps are being written to stdout. */ char *deps_file = 0; /* Fopen file mode to open deps_file with. */ char *deps_mode = "a"; /* Stream on which to print the dependency information. */ FILE *deps_stream = 0; /* Target-name to write with the dependency information. */ char *deps_target = 0;#ifdef RLIMIT_STACK /* Get rid of any avoidable limit on stack size. */ { struct rlimit rlim; /* Set the stack limit huge so that alloca (particularly stringtab in dbxread.c) does not fail. */ getrlimit (RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max; setrlimit (RLIMIT_STACK, &rlim); }#endif /* RLIMIT_STACK defined */#ifdef SIGPIPE signal (SIGPIPE, pipe_closed);#endif progname = base_name (argv[0]);#ifdef VMS { /* Remove extension from PROGNAME. */ char *p; char *s = progname = savestring (progname); if ((p = rindex (s, ';')) != 0) *p = '\0'; /* strip version number */ if ((p = rindex (s, '.')) != 0 /* strip type iff ".exe" */ && (p[1] == 'e' || p[1] == 'E') && (p[2] == 'x' || p[2] == 'X') && (p[3] == 'e' || p[3] == 'E') && !p[4]) *p = '\0'; }#endif in_fname = NULL; out_fname = NULL; /* Initialize is_idchar. */ initialize_char_syntax (); no_line_directives = 0; no_trigraphs = 1; dump_macros = dump_none; no_output = 0; cplusplus = 0; cplusplus_comments = 1; bzero ((char *) pend_files, argc * sizeof (char *)); bzero ((char *) pend_defs, argc * sizeof (char *)); bzero ((char *) pend_undefs, argc * sizeof (char *)); bzero ((char *) pend_assertions, argc * sizeof (char *)); bzero ((char *) pend_includes, argc * sizeof (char *)); /* Process switches and find input file name. */ for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { if (out_fname != NULL) fatal ("Usage: %s [switches] input output", argv[0]); else if (in_fname != NULL) out_fname = argv[i]; else in_fname = argv[i]; } else { switch (argv[i][1]) { case 'i': if (!strcmp (argv[i], "-include")) { if (i + 1 == argc) fatal ("Filename missing after `-include' option"); else { /* removed undefined behavior 28-JAN-2000 12:05:36.43 bcv */ int tmp=i; simplify_filename (pend_includes[tmp] = argv[++i]); } } if (!strcmp (argv[i], "-imacros")) { if (i + 1 == argc) fatal ("Filename missing after `-imacros' option"); else { /* removed undefined behavior 28-JAN-2000 12:05:36.43 bcv */ int tmp=i; simplify_filename (pend_files[tmp] = argv[++i]); } } if (!strcmp (argv[i], "-iprefix")) { if (i + 1 == argc) fatal ("Filename missing after `-iprefix' option"); else include_prefix = argv[++i]; } if (!strcmp (argv[i], "-ifoutput")) { output_conditionals = 1; } if (!strcmp (argv[i], "-isystem")) { struct file_name_list *dirtmp; if (! (dirtmp = new_include_prefix (NULL_PTR, "", argv[++i]))) break; dirtmp->c_system_include_path = 1; if (before_system == 0) before_system = dirtmp; else last_before_system->next = dirtmp; last_before_system = dirtmp; /* Tail follows the last one */ } /* Add directory to end of path for includes, with the default prefix at the front of its name. */ if (!strcmp (argv[i], "-iwithprefix")) { struct file_name_list *dirtmp; char *prefix; if (include_prefix != 0) prefix = include_prefix; else { prefix = savestring (GCC_INCLUDE_DIR); /* Remove the `include' from /usr/local/lib/gcc.../include. */ if (!strcmp (prefix + strlen (prefix) - 8, "/include")) prefix[strlen (prefix) - 7] = 0; } if (! (dirtmp = new_include_prefix (NULL_PTR, prefix, argv[++i]))) break; if (after_include == 0) after_include = dirtmp; else last_after_include->next = dirtmp; last_after_include = dirtmp; /* Tail follows the last one */ } /* Add directory to main path for includes, with the default prefix at the front of its name. */ if (!strcmp (argv[i], "-iwithprefixbefore")) { struct file_name_list *dirtmp; char *prefix; if (include_prefix != 0) prefix = include_prefix; else { prefix = savestring (GCC_INCLUDE_DIR); /* Remove the `include' from /usr/local/lib/gcc.../include. */ if (!strcmp (prefix + strlen (prefix) - 8, "/include")) prefix[strlen (prefix) - 7] = 0; } dirtmp = new_include_prefix (NULL_PTR, prefix, argv[++i]); append_include_chain (dirtmp, dirtmp); } /* Add directory to end of path for includes. */ if (!strcmp (argv[i], "-idirafter")) { struct file_name_list *dirtmp; if (! (dirtmp = new_include_prefix (NULL_PTR, "", argv[++i]))) break; if (after_include == 0) after_include = dirtmp; else last_after_include->next = dirtmp; last_after_include = dirtmp; /* Tail follows the last one */ } break; case 'o': if (out_fname != NULL) fatal ("Output filename specified twice"); if (i + 1 == argc) fatal ("Filename missing after -o option"); out_fname = argv[++i]; if (!strcmp (out_fname, "-")) out_fname = ""; break; case 'p': if (!strcmp (argv[i], "-pedantic")) pedantic = 1; else if (!strcmp (argv[i], "-pedantic-errors")) { pedantic = 1; pedantic_errors = 1; } else if (!strcmp (argv[i], "-pcp")) { char *pcp_fname; if (i + 1 == argc) fatal ("Filename missing after -pcp option"); pcp_fname = argv[++i]; pcp_outfile = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0') ? fopen (pcp_fname, "w") : stdout); if (pcp_outfile == 0) pfatal_with_name (pcp_fname); no_precomp = 1; } break; case 't': if (!strcmp (argv[i], "-traditional")) { traditional = 1; cplusplus_comments = 0; } else if (!strcmp (argv[i], "-trigraphs")) { no_trigraphs = 0; } break; case 'l': if (! strcmp (argv[i], "-lang-c")) cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 0; if (! strcmp (argv[i], "-lang-c89")) cplusplus = 0, cplusplus_comments = 0, c89 = 1, objc = 0; if (! strcmp (argv[i], "-lang-c++")) cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 0; if (! strcmp (argv[i], "-lang-objc")) cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 1; if (! strcmp (argv[i], "-lang-objc++")) cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 1; if (! strcmp (argv[i], "-lang-asm")) lang_asm = 1; if (! strcmp (argv[i], "-lint")) for_lint = 1; break; case '+': cplusplus = 1, cplusplus_comments = 1; break; case 'w': inhibit_warnings = 1; break; case 'W': if (!strcmp (argv[i], "-Wtrigraphs")) warn_trigraphs = 1; else if (!strcmp (argv[i], "-Wno-trigraphs")) warn_trigraphs = 0; else if (!strcmp (argv[i], "-Wcomment")) warn_comments = 1; else if (!strcmp (argv[i], "-Wno-comment")) warn_comments = 0; else if (!strcmp (argv[i], "-Wcomments")) warn_comments = 1; else if (!strcmp (argv[i], "-Wno-comments")) warn_comments = 0; else if (!strcmp (argv[i], "-Wtraditional")) warn_stringify = 1; else if (!strcmp (argv[i], "-Wno-traditional")) warn_stringify = 0; else if (!strcmp (argv[i], "-Wundef")) warn_undef = 1; else if (!strcmp (argv[i], "-Wno-undef")) warn_undef = 0; else if (!strcmp (argv[i], "-Wimport")) warn_import = 1; else if (!strcmp (argv[i], "-Wno-import")) warn_import = 0; else if (!strcmp (argv[i], "-Werror")) warnings_are_errors = 1; else if (!strcmp (argv[i], "-Wno-error")) warnings_are_errors = 0; else if (!strcmp (argv[i], "-Wall")) { warn_trigraphs = 1; warn_comments = 1; } break; case 'M': /* The style of the choices here is a bit mixed. The chosen scheme is a hybrid of keeping all options in one string and specifying each option in a separate argument: -M|-MM|-MD file|-MMD file [-MG]. An alternative is: -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: -M[M][G][D file]. This is awkward to handle in specs, and is not as extensible. */ /* ??? -MG must be specified in addition to one of -M or -MM. This can be relaxed in the future without breaking anything. The converse isn't true. */ /* -MG isn't valid with -MD or -MMD. This is checked for later. */ if (!strcmp (argv[i], "-MG")) { print_deps_missing_files = 1; break; } if (!strcmp (argv[i], "-M")) print_deps = 2; else if (!strcmp (argv[i], "-MM")) print_deps = 1; else if (!strcmp (argv[i], "-MD")) print_deps = 2; else if (!strcmp (argv[i], "-MMD")) print_deps = 1; /* For -MD and -MMD options, write deps on file named by next arg. */ if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD")) { if (i + 1 == argc) fatal ("Filename missing after %s option", argv[i]); i++; deps_file = argv[i]; deps_mode = "w"; } else { /* For -M and -MM, write deps on standard output and suppress the usual output. */ deps_stream = stdout; inhibit_output = 1; } break; case 'd': { char *p = argv[i] + 2; char c; while ((c = *p++)) { /* Arg to -d specifies what parts of macros to dump */ switch (c) { case 'M': dump_macros = dump_only; no_output = 1; break; case 'N': dump_macros = dump_names; break; case 'D': dump_macros = dump_definitions; break; } } } break; case 'g': if (argv[i][2] == '3') debug_output = 1; break; case 'v': fprintf (stderr, "GNU CPP version %s", version_string);#ifdef TARGET_VERSION TARGET_VERSION;#endif fprintf (stderr, "\n"); verbose = 1; break; case 'H': print_include_names = 1; break; case 'D': if (argv[i][2] != 0) pend_defs[i] = argv[i] + 2; else if (i + 1 == argc) fatal ("Macro name missing after -D option"); else i++, pend_defs[i] = argv[i]; break; case 'A': { char *p; if (argv[i][2] != 0) p = argv[i] + 2; else if (i + 1 == argc) fatal ("Assertion missing after -A option"); else p = argv[++i]; if (!strcmp (p, "-")) { /* -A- eliminates all predefined macros and assertions. Let's include also any that were specified earlier on the command line. That way we can get rid of any that were passed automatically in from GCC. */ int j; inhibit_predefs = 1; for (j = 0; j < i; j++) pend_defs[j] = pend_assertions[j] = 0; } else { pend_assertions[i] = p; pend_assertion_options[i] = "-A"; } } break; case 'U': /* JF #undef something */ if (argv[i][2] != 0) pend_undefs[i] = argv[i] + 2; else if (i + 1 == argc) fatal ("Macro name missing after -U option"); else pend_undefs[i] = argv[i+1], i++; break; case 'C': put_out_comments = 1; break; case 'E': /* -E comes from cc -E; ignore it. */ break; case 'P': no_line_directives = 1; break; case '$': /* Don't include $ in identifiers. */ is_idchar['$'] = is_idstart['$'] = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -