From 05364072042ff37904a7b0b14cdd85a1ea1ca11d Mon Sep 17 00:00:00 2001 From: seyko Date: Sun, 12 Apr 2015 15:35:37 +0300 Subject: ability to specify a type of the input file with the -x switch Usage example: tcc -xc ex5.cgi From a gcc docs: You can specify the input language explicitly with the -x option: -x language Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next -x option. Possible values for language are: c c-header c-cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada f77 f77-cpp-input f95 f95-cpp-input java -x none Turn off any specification of a language, so that subsequent files are handled according to their file name suffixes (as they are if -x has not been used at all) --- tcc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tcc.c') diff --git a/tcc.c b/tcc.c index 5815ade..779f894 100644 --- a/tcc.c +++ b/tcc.c @@ -312,9 +312,8 @@ int main(int argc, char **argv) /* compile or add each files or library */ for(i = ret = 0; i < s->nb_files && ret == 0; i++) { - const char *filename; - - filename = s->files[i]; + int filetype = *(unsigned char *)s->files[i]; + const char *filename = s->files[i] + 1; if (filename[0] == '-' && filename[1] == 'l') { if (tcc_add_library(s, filename + 2) < 0) { tcc_error_noabort("cannot find '%s'", filename); @@ -323,7 +322,7 @@ int main(int argc, char **argv) } else { if (1 == s->verbose) printf("-> %s\n", filename); - if (tcc_add_file(s, filename) < 0) + if (tcc_add_file(s, filename, filetype) < 0) ret = 1; if (!first_file) first_file = filename; -- cgit v1.3.1