* get rid of diagnistic.[ch], pretty-print.[ch],
[fw/sdcc] / support / cpp2 / sdcpp.h
1 #ifndef __SDCPP_H
2 #define __SDCPP_H
3
4 #ifdef _WIN32
5 #include <string.h>
6 #ifdef __BORLANDC__
7 #define strcasecmp  stricmp
8 #else
9 #define strcasecmp  _stricmp
10 #endif
11 #endif
12 #define BYTES_BIG_ENDIAN  0
13
14 #if defined _MSC_VER || defined __MINGW32__ || defined __BORLANDC__
15 /*
16  * The following define causes the following warning:
17  * warning: `I' flag used with `%x' printf format
18  * when copiled with mingw or cygwin -mno-cygwin gcc.
19  * This is correct, because the mingw compilation links against msvcrt.dll,
20  * which uses "I46" for 64 bit integer (long long) printf lenght modifier,
21  * instead of "ll" used by libc.
22  */
23 #define PRINTF_INT64_MODIFIER "I64"
24 typedef __int64 long_long;
25 #else
26 #define PRINTF_INT64_MODIFIER "ll"
27 typedef long long long_long;
28 #endif
29
30 /*
31  * From defaults.h
32  */
33 #ifndef GET_ENVIRONMENT
34 #define GET_ENVIRONMENT(VALUE, NAME) do { (VALUE) = getenv (NAME); } while (0)
35 #endif
36
37 /* Define results of standard character escape sequences.  */
38 #define TARGET_BELL     007
39 #define TARGET_BS       010
40 #define TARGET_TAB      011
41 #define TARGET_NEWLINE  012
42 #define TARGET_VT       013
43 #define TARGET_FF       014
44 #define TARGET_CR       015
45 #define TARGET_ESC      033
46
47 #define CHAR_TYPE_SIZE 8
48 #define WCHAR_TYPE_SIZE 32      /* ? maybe ? */
49
50 #define SUPPORTS_ONE_ONLY 0
51
52 #define TARGET_OBJECT_SUFFIX ".rel"
53
54 #ifndef WCHAR_UNSIGNED
55 #define WCHAR_UNSIGNED 0
56 #endif
57
58 /*
59  * From langhooks.h
60  */
61 struct diagnostic_context;
62
63 struct lang_hooks
64 {
65   /* The first callback made to the front end, for simple
66      initialization needed before any calls to handle_option.  Return
67      the language mask to filter the switch array with.  */
68   unsigned int (*init_options) (unsigned int argc, const char **argv);
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
104 /* Each front end provides its own.  */
105 extern const struct lang_hooks lang_hooks;
106
107 /*
108  * From toplev.h
109  */
110 /* If we haven't already defined a frontend specific diagnostics
111    style, use the generic one.  */
112 #ifndef GCC_DIAG_STYLE
113 #define GCC_DIAG_STYLE __gcc_diag__
114 #endif
115 /* None of these functions are suitable for ATTRIBUTE_PRINTF, because
116    each language front end can extend them with its own set of format
117    specifiers.  We must use custom format checks.  */
118 #if GCC_VERSION >= 4001
119 #define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
120 #else
121 #define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
122 #endif
123 extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
124      ATTRIBUTE_NORETURN;
125 /* Pass one of the OPT_W* from options.h as the first parameter.  */
126 extern void warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
127 extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
128 extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
129      ATTRIBUTE_NORETURN;
130 extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
131
132 extern bool exit_after_options;
133
134 extern void print_version (FILE *, const char *);
135
136 /* Handle -d switch.  */
137 extern void decode_d_option (const char *);
138
139 /* Functions used to get and set GCC's notion of in what directory
140    compilation was started.  */
141
142 extern const char *get_src_pwd (void);
143 extern bool set_src_pwd (const char *);
144
145 /*
146  * From flags.h
147  */
148 /* Don't suppress warnings from system headers.  -Wsystem-headers.  */
149
150 extern bool warn_system_headers;
151
152 /* If -Werror.  */
153
154 extern bool warnings_are_errors;
155
156 /* Nonzero for -pedantic switch: warn about anything
157    that standard C forbids.  */
158
159 /* Temporarily suppress certain warnings.
160    This is set while reading code from a system header file.  */
161
162 extern int in_system_header;
163
164 /* Nonzero means `char' should be signed.  */
165
166 extern int flag_signed_char;
167
168 /* Nonzero means change certain warnings into errors.
169    Usually these are warnings about failure to conform to some standard.  */
170
171 extern int flag_pedantic_errors;
172
173 /*
174  * From c-common.h
175  */
176 #include "hwint.h"
177 #include "cpplib.h"
178
179 /* Nonzero means don't output line number information.  */
180
181 extern char flag_no_line_commands;
182
183 /* Nonzero causes -E output not to be done, but directives such as
184    #define that have side effects are still obeyed.  */
185
186 extern char flag_no_output;
187
188 /* Nonzero means dump macros in some fashion; contains the 'D', 'M' or
189    'N' of the command line switch.  */
190
191 extern char flag_dump_macros;
192
193 /* 0 means we want the preprocessor to not emit line directives for
194    the current working directory.  1 means we want it to do it.  -1
195    means we should decide depending on whether debugging information
196    is being emitted or not.  */
197
198 extern int flag_working_directory;
199
200 /* Nonzero means warn about usage of long long when `-pedantic'.  */
201
202 extern int warn_long_long;
203
204 extern int sdcpp_common_handle_option (size_t code, const char *arg, int value);
205 extern bool sdcpp_common_missing_argument (const char *opt, size_t code);
206 extern unsigned int sdcpp_common_init_options (unsigned int, const char **);
207 extern bool sdcpp_common_post_options (const char **);
208 extern bool sdcpp_common_init (void);
209 extern void sdcpp_common_finish (void);
210
211 /* Nonzero means pass #include lines through to the output.  */
212
213 extern char flag_dump_includes;
214
215 /* In c-ppoutput.c  */
216 extern void init_pp_output (FILE *);
217 extern void preprocess_file (cpp_reader *);
218 extern void pp_file_change (const struct line_map *);
219 extern void pp_dir_change (cpp_reader *, const char *);
220
221 /*
222  * From c-pragma.h
223  */
224 extern struct cpp_reader* parse_in;
225
226 /*
227  * From input.h
228  */
229 extern struct line_maps line_table;
230
231 typedef source_location location_t; /* deprecated typedef */
232
233 /* Top-level source file.  */
234 extern const char *main_input_filename;
235
236 /*
237  * From tree.h
238  */
239 /* Define the overall contents of a tree node.
240    just to make diagnostic.c happy  */
241
242 union tree_node
243 {
244   struct tree_decl
245   {
246     location_t locus;
247   } decl;
248 };
249
250 #define DECL_SOURCE_LOCATION(NODE) ((NODE)->decl.locus)
251
252 /*
253  * From diagnostic.h
254  */
255 extern int errorcount;
256
257
258 #endif  /* __SDCPP_H */