carries all the options visible to the command line. */
struct cpp_options
{
- /* Name of input and output files. */
- const char *in_fname;
- const char *out_fname;
-
/* Characters between tab stops. */
unsigned int tabstop;
/* Pending options - -D, -U, -A, -I, -ixxx. */
struct cpp_pending *pending;
- /* File name which deps are being written to. This is 0 if deps are
- being written to stdout. */
- const char *deps_file;
-
/* Search paths for include files. */
struct search_path *quote_include; /* "" */
struct search_path *bracket_include; /* <> */
/* Nonzero means to allow hexadecimal floats and LL suffixes. */
unsigned char extended_numbers;
- /* Nonzero means print the names of included files rather than the
- preprocessed output. 1 means just the #include "...", 2 means
- #include <...> as well. */
- unsigned char print_deps;
-
- /* Nonzero if phony targets are created for each header. */
- unsigned char deps_phony_targets;
-
- /* Nonzero if missing .h files in -M output are assumed to be
- generated files and not errors. */
- unsigned char print_deps_missing_files;
-
- /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
- unsigned char print_deps_append;
-
/* Nonzero means print names of header files (-H). */
unsigned char print_include_names;
traditional C. */
unsigned char warn_traditional;
+ /* Nonzero means warn about long long numeric constants. */
+ unsigned char warn_long_long;
+
/* Nonzero means warn about text after an #endif (or #else). */
unsigned char warn_endif_labels;
+ /* Nonzero means warn about implicit sign changes owing to integer
+ promotions. */
+ unsigned char warn_num_sign_change;
+
/* Nonzero means turn warnings into errors. */
unsigned char warnings_are_errors;
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */
unsigned char warn_undef;
+ /* Nonzero means warn of unused macros from the main file. */
+ unsigned char warn_unused_macros;
+
/* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
unsigned char c99;
+ /* Nonzero if we are conforming to a specific C or C++ standard. */
+ unsigned char std;
+
/* Nonzero means give all the error messages the ANSI standard requires. */
unsigned char pedantic;
/* Nonzero means handle C++ alternate operator names. */
unsigned char operator_names;
- /* True if --help, --version or --target-help appeared in the
- options. Stand-alone CPP should then bail out after option
- parsing; drivers might want to continue printing help. */
- unsigned char help_only;
-
/* True for traditional preprocessing. */
unsigned char traditional;
+ /* Dependency generation. */
+ struct
+ {
+ /* Style of header dependencies to generate. */
+ enum {DEPS_NONE = 0, DEPS_USER, DEPS_SYSTEM } style;
+
+ /* Assume missing files are generated files. */
+ bool missing_files;
+
+ /* Generate phony targets for each dependency apart from the first
+ one. */
+ bool phony_targets;
+
+ /* If true, no dependency is generated on the main file. */
+ bool ignore_main_file;
+ } deps;
+
/* Target-specific features set by the front end or client. */
/* Precision for target CPP arithmetic, target characters, target
ints and target wide characters, respectively. */
size_t precision, char_precision, int_precision, wchar_precision;
- /* Nonzero means chars (wide chars) are unsigned. */
- unsigned char unsigned_char, unsigned_wchar;
+ /* True means chars (wide chars) are unsigned. */
+ bool unsigned_char, unsigned_wchar;
/* Nonzero means __STDC__ should have the value 0 in system headers. */
unsigned char stdc_0_in_system_headers;
void (*register_builtins) PARAMS ((cpp_reader *));
};
-#define CPP_FATAL_LIMIT 1000
-/* True if we have seen a "fatal" error. */
-#define CPP_FATAL_ERRORS(PFILE) (cpp_errors (PFILE) >= CPP_FATAL_LIMIT)
-
/* Name under which this program was invoked. */
extern const char *progname;
/* Call this first to get a handle to pass to other functions. */
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
+/* Call this to change the selected language standard (e.g. because of
+ command line options). */
+extern void cpp_set_lang PARAMS ((cpp_reader *, enum c_lang));
+
+/* Add a dependency TARGET. Quote it for "make" if QUOTE. Can be
+ called any number of times before cpp_read_main_file(). If no
+ targets have been added before cpp_read_main_file(), then the
+ default target is used. */
+extern void cpp_add_dependency_target PARAMS ((cpp_reader *,
+ const char * target,
+ int quote));
+
/* Call these to get pointers to the options and callback structures
for a given reader. These pointers are good until you call
cpp_finish on that reader. You can either edit the callbacks
/* Now call cpp_handle_option[s] to handle 1[or more] switches. The
return value is the number of arguments used. If
cpp_handle_options returns without using all arguments, it couldn't
- understand the next switch. When there are no switches left, you
- must call cpp_post_options before calling cpp_read_main_file. Only
- after cpp_post_options are the contents of the cpp_options
- structure reliable. Options processing is not completed until you
- call cpp_finish_options. */
+ understand the next switch. Options processing is not completed
+ until you call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
-extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **, int));
-extern void cpp_post_options PARAMS ((cpp_reader *));
+extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
/* This function reads the file, but does not start preprocessing. It
returns the name of the original file; this is the same as the
from cpp_read_main_file, before they get debug callbacks. */
extern void cpp_finish_options PARAMS ((cpp_reader *));
+/* Call this to finish preprocessing. If you requested dependency
+ generation, pass an open stream to write the information to,
+ otherwise NULL. It is your responsibility to close the stream.
+
+ Returns cpp_errors (pfile). */
+extern int cpp_finish PARAMS ((cpp_reader *, FILE *deps_stream));
+
/* Call this to release the handle at the end of preprocessing. Any
use of the handle after this function returns is invalid. Returns
cpp_errors (pfile). */
-extern int cpp_destroy PARAMS ((cpp_reader *));
+extern void cpp_destroy PARAMS ((cpp_reader *));
/* Error count. */
extern unsigned int cpp_errors PARAMS ((cpp_reader *));
const char *, const char *,
void (*) PARAMS ((cpp_reader *))));
-extern void cpp_finish PARAMS ((cpp_reader *));
extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *,
const cpp_token *));
extern const cpp_token *cpp_get_token PARAMS ((cpp_reader *));
int, int));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
+/* A preprocessing number. Code assumes that any unused high bits of
+ the double integer are set to zero. */
+typedef unsigned HOST_WIDE_INT cpp_num_part;
+typedef struct cpp_num cpp_num;
+struct cpp_num
+{
+ cpp_num_part high;
+ cpp_num_part low;
+ bool unsignedp; /* True if value should be treated as unsigned. */
+ bool overflow; /* True if the most recent calculation overflowed. */
+};
+
+/* cpplib provides two interfaces for interpretation of preprocessing
+ numbers.
+
+ cpp_classify_number categorizes numeric constants according to
+ their field (integer, floating point, or invalid), radix (decimal,
+ octal, hexadecimal), and type suffixes. */
+
+#define CPP_N_CATEGORY 0x000F
+#define CPP_N_INVALID 0x0000
+#define CPP_N_INTEGER 0x0001
+#define CPP_N_FLOATING 0x0002
+
+#define CPP_N_WIDTH 0x00F0
+#define CPP_N_SMALL 0x0010 /* int, float. */
+#define CPP_N_MEDIUM 0x0020 /* long, double. */
+#define CPP_N_LARGE 0x0040 /* long long, long double. */
+
+#define CPP_N_RADIX 0x0F00
+#define CPP_N_DECIMAL 0x0100
+#define CPP_N_HEX 0x0200
+#define CPP_N_OCTAL 0x0400
+
+#define CPP_N_UNSIGNED 0x1000 /* Properties. */
+#define CPP_N_IMAGINARY 0x2000
+
+/* Classify a CPP_NUMBER token. The return value is a combination of
+ the flags from the above sets. */
+extern unsigned cpp_classify_number PARAMS ((cpp_reader *, const cpp_token *));
+
+/* Evaluate a token classified as category CPP_N_INTEGER. */
+extern cpp_num cpp_interpret_integer PARAMS ((cpp_reader *, const cpp_token *,
+ unsigned int type));
+
+/* Sign extend a number, with PRECISION significant bits and all
+ others assumed clear, to fill out a cpp_num structure. */
+cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t));
+
/* Diagnostic levels. To get a dianostic without associating a
position in the translation unit with it, use cpp_error_with_line
with a line number of zero. */
#define DL_PEDWARN 0x02
/* An error. */
#define DL_ERROR 0x03
-/* A fatal error. We do not exit, to support use of cpplib as a
- library, but may only return CPP_EOF tokens thereon. It is the
- caller's responsibility to check CPP_FATAL_ERRORS. */
-#define DL_FATAL 0x04
/* An internal consistency check failed. Prints "internal error: ",
- otherwise the same as DL_FATAL. */
-#define DL_ICE 0x05
+ otherwise the same as DL_ERROR. */
+#define DL_ICE 0x04
/* Extracts a diagnostic level from an int. */
#define DL_EXTRACT(l) (l & 0xf)
/* Non-zero if a diagnostic level is one of the warnings. */
extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
/* In cppmain.c */
-extern void cpp_preprocess_file PARAMS ((cpp_reader *));
+extern void cpp_preprocess_file PARAMS ((cpp_reader *, const char *, FILE *));
#ifdef __cplusplus
}