* SDCPP synchronized with GCC CPP release version 3.4.6,
[fw/sdcc] / support / cpp2 / sdcpp.h
1 #ifndef __SDCPP_H
2 #define __SDCPP_H
3
4 #ifdef _WIN32
5 #include <string.h>
6 #define strcasecmp  _stricmp
7 #endif
8 #define BYTES_BIG_ENDIAN  0
9
10 #if defined _MSC_VER || defined __MINGW32__
11 /*
12  * The following define causes the following warning:
13  * warning: `I' flag used with `%x' printf format
14  * when copiled with mingw or cygwin -mno-cygwin gcc.
15  * This is correct, because the mingw compilation links against msvcrt.dll,
16  * which uses "I46" for 64 bit integer (long long) printf lenght modifier,
17  * instead of "ll" used by libc.
18  */
19 #define PRINTF_INT64_MODIFIER "I64"
20 typedef __int64 long_long;
21 #else
22 #define PRINTF_INT64_MODIFIER "ll"
23 typedef long long long_long;
24 #endif
25
26 /*
27  * From defaults.h
28  */
29 #ifndef GET_ENVIRONMENT
30 #define GET_ENVIRONMENT(VALUE, NAME) do { (VALUE) = getenv (NAME); } while (0)
31 #endif
32
33 /* Define results of standard character escape sequences.  */
34 #define TARGET_BELL     007
35 #define TARGET_BS       010
36 #define TARGET_TAB      011
37 #define TARGET_NEWLINE  012
38 #define TARGET_VT       013
39 #define TARGET_FF       014
40 #define TARGET_CR       015
41 #define TARGET_ESC      033
42
43 #define CHAR_TYPE_SIZE 8
44 #define WCHAR_TYPE_SIZE 32      /* ? maybe ? */
45
46 #define SUPPORTS_ONE_ONLY 0
47
48 #define TARGET_OBJECT_SUFFIX ".rel"
49
50 #ifndef WCHAR_UNSIGNED
51 #define WCHAR_UNSIGNED 0
52 #endif
53
54 /*
55  * From langhooks.h
56  */
57 struct diagnostic_context;
58
59 struct lang_hooks
60 {
61   /* The first callback made to the front end, for simple
62      initialization needed before any calls to handle_option.  Return
63      the language mask to filter the switch array with.  */
64   unsigned int (*init_options) (unsigned int argc, const char **argv);
65
66   /* Callback used to perform language-specific initialization for the
67      global diagnostic context structure.  */
68   void (*initialize_diagnostics) (struct diagnostic_context *);
69
70   /* Handle the switch CODE, which has real type enum opt_code from
71      options.h.  If the switch takes an argument, it is passed in ARG
72      which points to permanent storage.  The handler is responsible for
73      checking whether ARG is NULL, which indicates that no argument
74      was in fact supplied.  For -f and -W switches, VALUE is 1 or 0
75      for the positive and negative forms respectively.
76
77      Return 1 if the switch is valid, 0 if invalid, and -1 if it's
78      valid and should not be treated as language-independent too.  */
79   int (*handle_option) (size_t code, const char *arg, int value);
80
81   /* Return false to use the default complaint about a missing
82      argument, otherwise output a complaint and return true.  */
83   bool (*missing_argument) (const char *opt, size_t code);
84
85   /* Called when all command line options have been parsed to allow
86      further processing and initialization
87
88      Should return true to indicate that a compiler back-end is
89      not required, such as with the -E option.
90
91      If errorcount is nonzero after this call the compiler exits
92      immediately and the finish hook is not called.  */
93   bool (*post_options) (const char **);
94
95   /* Called after post_options to initialize the front end.  Return
96      false to indicate that no further compilation be performed, in
97      which case the finish hook is called immediately.  */
98   bool (*init) (void);
99
100   /* Called at the end of compilation, as a finalizer.  */
101   void (*finish) (void);
102
103   /* Called by report_error_function to print out function name.  */
104   void (*print_error_function) (struct diagnostic_context *, const char *);
105 };
106
107 /* Each front end provides its own.  */
108 extern const struct lang_hooks lang_hooks;
109
110 /*
111  * From toplev.h
112  */
113 /* If we haven't already defined a frontend specific diagnostics
114    style, use the generic one.  */
115 #ifndef GCC_DIAG_STYLE
116 #define GCC_DIAG_STYLE __gcc_diag__
117 #endif
118
119 /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
120    each language front end can extend them with its own set of format
121    specifiers.  We must use custom format checks.  */
122 #if GCC_VERSION >= 3004
123 #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
124 #else
125 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
126 #endif
127 extern void warning (const char *, ...);
128 extern void error (const char *, ...);
129 extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
130      ATTRIBUTE_NORETURN;
131
132 #ifdef BUFSIZ
133   /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
134      therefore it can have ATTRIBUTE_PRINTF.  */
135 extern void fnotice                     (FILE *, const char *, ...)
136      ATTRIBUTE_PRINTF_2;
137 #endif
138
139 extern bool exit_after_options;
140
141 extern void print_version (FILE *, const char *);
142
143 /* Handle -d switch.  */
144 extern void decode_d_option (const char *);
145
146 /* Functions used to get and set GCC's notion of in what directory
147    compilation was started.  */
148
149 extern const char *get_src_pwd (void);
150 extern bool set_src_pwd (const char *);
151
152 /*
153  * From flags.h
154  */
155 /* Don't suppress warnings from system headers.  -Wsystem-headers.  */
156
157 extern bool warn_system_headers;
158
159 /* If -Werror.  */
160
161 extern bool warnings_are_errors;
162
163 /* Nonzero for -pedantic switch: warn about anything
164    that standard C forbids.  */
165
166 /* Temporarily suppress certain warnings.
167    This is set while reading code from a system header file.  */
168
169 extern int in_system_header;
170
171 /* Nonzero means `char' should be signed.  */
172
173 extern int flag_signed_char;
174
175 /* Nonzero means change certain warnings into errors.
176    Usually these are warnings about failure to conform to some standard.  */
177
178 extern int flag_pedantic_errors;
179
180 /* Don't print warning messages.  -w.  */
181
182 extern bool inhibit_warnings;
183
184 /*
185  * From c-common.h
186  */
187 #include "cpplib.h"
188
189 /* Nonzero means don't output line number information.  */
190
191 extern char flag_no_line_commands;
192
193 /* Nonzero causes -E output not to be done, but directives such as
194    #define that have side effects are still obeyed.  */
195
196 extern char flag_no_output;
197
198 /* Nonzero means dump macros in some fashion; contains the 'D', 'M' or
199    'N' of the command line switch.  */
200
201 extern char flag_dump_macros;
202
203 /* 0 means we want the preprocessor to not emit line directives for
204    the current working directory.  1 means we want it to do it.  -1
205    means we should decide depending on whether debugging information
206    is being emitted or not.  */
207
208 extern int flag_working_directory;
209
210 /* Nonzero means warn about usage of long long when `-pedantic'.  */
211
212 extern int warn_long_long;
213
214 extern int sdcpp_common_handle_option (size_t code, const char *arg, int value);
215 extern bool sdcpp_common_missing_argument (const char *opt, size_t code);
216 extern unsigned int sdcpp_common_init_options (unsigned int, const char **);
217 extern bool sdcpp_common_post_options (const char **);
218 extern bool sdcpp_common_init (void);
219 extern void sdcpp_common_finish (void);
220
221 /* Nonzero means pass #include lines through to the output.  */
222
223 char flag_dump_includes;
224
225 /* In c-ppoutput.c  */
226 extern void init_pp_output (FILE *);
227 extern void preprocess_file (cpp_reader *);
228 extern void pp_file_change (const struct line_map *);
229 extern void pp_dir_change (cpp_reader *, const char *);
230
231 /*
232  * From c-pragma.h
233  */
234 extern struct cpp_reader* parse_in;
235
236 /*
237  * From tree.h
238  */
239 #include "input.h"
240
241 /* Define the overall contents of a tree node.
242    just to make diagnostic.c happy  */
243
244 union tree_node
245 {
246   struct tree_decl
247   {
248     location_t locus;
249   } decl;
250 };
251
252 #define DECL_SOURCE_LOCATION(NODE) ((NODE)->decl.locus)
253
254 #endif  /* __SDCPP_H */