comparison main.c @ 159:8cef6d7227a8

Expand __FILE__ and __LINE__.
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 27 Feb 2015 00:41:46 +0100
parents 1a7de2c68290
children 3e7e696fe558
comparison
equal deleted inserted replaced
158:19278e2f885d 159:8cef6d7227a8
193 array_setsize(&commandline_macros, 0); 193 array_setsize(&commandline_macros, 0);
194 } 194 }
195 195
196 static 196 static
197 void 197 void
198 apply_special_macros(unsigned *builtin_counter)
199 {
200 struct place p;
201
202 place_setbuiltin(&p, ++(*builtin_counter));
203 macro_define_file(&p);
204 place_setbuiltin(&p, ++(*builtin_counter));
205 macro_define_line(&p);
206 }
207
208 static
209 void
198 apply_builtin_macro(unsigned num, const char *name, const char *val) 210 apply_builtin_macro(unsigned num, const char *name, const char *val)
199 { 211 {
200 struct place p; 212 struct place p;
201 213
202 place_setbuiltin(&p, num); 214 place_setbuiltin(&p, num);
203 macro_define_plain(&p, name, &p, val); 215 macro_define_plain(&p, name, &p, val);
204 } 216 }
205 217
206 static 218 static
207 void 219 void
208 apply_builtin_macros(void) 220 apply_builtin_macros(unsigned *builtin_counter)
209 { 221 {
210 unsigned n = 1;
211
212 #ifdef CONFIG_OS 222 #ifdef CONFIG_OS
213 apply_builtin_macro(n++, CONFIG_OS, "1"); 223 apply_builtin_macro(++(*builtin_counter), CONFIG_OS, "1");
214 #endif 224 #endif
215 #ifdef CONFIG_OS_2 225 #ifdef CONFIG_OS_2
216 apply_builtin_macro(n++, CONFIG_OS_2, "1"); 226 apply_builtin_macro(++(*builtin_counter), CONFIG_OS_2, "1");
217 #endif 227 #endif
218 228
219 #ifdef CONFIG_CPU 229 #ifdef CONFIG_CPU
220 apply_builtin_macro(n++, CONFIG_CPU, "1"); 230 apply_builtin_macro(++(*builtin_counter), CONFIG_CPU, "1");
221 #endif 231 #endif
222 #ifdef CONFIG_CPU_2 232 #ifdef CONFIG_CPU_2
223 apply_builtin_macro(n++, CONFIG_CPU_2, "1"); 233 apply_builtin_macro(++(*builtin_counter), CONFIG_CPU_2, "1");
224 #endif 234 #endif
225 235
226 #ifdef CONFIG_SIZE 236 #ifdef CONFIG_SIZE
227 apply_builtin_macro(n++, CONFIG_SIZE, "1"); 237 apply_builtin_macro(++(*builtin_counter), CONFIG_SIZE, "1");
228 #endif 238 #endif
229 #ifdef CONFIG_BINFMT 239 #ifdef CONFIG_BINFMT
230 apply_builtin_macro(n++, CONFIG_BINFMT, "1"); 240 apply_builtin_macro(++(*builtin_counter), CONFIG_BINFMT, "1");
231 #endif 241 #endif
232 242
233 #ifdef CONFIG_COMPILER 243 #ifdef CONFIG_COMPILER
234 apply_builtin_macro(n++, CONFIG_COMPILER, VERSION_MAJOR); 244 apply_builtin_macro(++(*builtin_counter), CONFIG_COMPILER,
235 apply_builtin_macro(n++, CONFIG_COMPILER_MINOR, VERSION_MINOR); 245 VERSION_MAJOR);
236 apply_builtin_macro(n++, "__VERSION__", VERSION_LONG); 246 apply_builtin_macro(++(*builtin_counter), CONFIG_COMPILER_MINOR,
247 VERSION_MINOR);
248 apply_builtin_macro(++(*builtin_counter), "__VERSION__", VERSION_LONG);
237 #endif 249 #endif
238 } 250 }
239 251
240 //////////////////////////////////////////////////////////// 252 ////////////////////////////////////////////////////////////
241 // extra included files 253 // extra included files
1029 { 1041 {
1030 const char *progname; 1042 const char *progname;
1031 const char *inputfile = NULL; 1043 const char *inputfile = NULL;
1032 const char *outputfile = NULL; 1044 const char *outputfile = NULL;
1033 struct place cmdplace; 1045 struct place cmdplace;
1046 unsigned builtin_counter;
1034 int i; 1047 int i;
1035 1048
1036 progname = strrchr(argv[0], '/'); 1049 progname = strrchr(argv[0], '/');
1037 progname = progname == NULL ? argv[0] : progname + 1; 1050 progname = progname == NULL ? argv[0] : progname + 1;
1038 complain_init(progname); 1051 complain_init(progname);
1074 } 1087 }
1075 1088
1076 mode.output_file = outputfile; 1089 mode.output_file = outputfile;
1077 1090
1078 loadincludepath(); 1091 loadincludepath();
1079 apply_builtin_macros(); 1092
1093 builtin_counter = 0;
1094 apply_special_macros(&builtin_counter);
1095 apply_builtin_macros(&builtin_counter);
1096
1080 apply_commandline_macros(); 1097 apply_commandline_macros();
1081 read_commandline_files(); 1098 read_commandline_files();
1082 place_setnowhere(&cmdplace); 1099 place_setnowhere(&cmdplace);
1083 file_readabsolute(&cmdplace, inputfile); 1100 file_readabsolute(&cmdplace, inputfile);
1084 1101