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