From 928514954898ee6c05d0495b0f84ed4e3fd42c71 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 27 Jun 2016 16:40:00 +0200 Subject: Implement -include cmdline option This option includes a file as if '#include "file"' is the first line of compiled files. It's processed after all -D/-U options and is processed per input file. --- tccpp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tccpp.c') diff --git a/tccpp.c b/tccpp.c index 6446c9c..151bce6 100644 --- a/tccpp.c +++ b/tccpp.c @@ -3480,6 +3480,20 @@ ST_FUNC void preprocess_start(TCCState *s1) s1->dollars_in_identifiers ? IS_ID : 0; isidnum_table['.' - CH_EOF] = (parse_flags & PARSE_FLAG_ASM_FILE) ? IS_ID : 0; + if (s1->nb_cmd_include_files) { + CString cstr; + int i; + cstr_new(&cstr); + for (i = 0; i < s1->nb_cmd_include_files; i++) { + cstr_cat(&cstr, "#include \"", -1); + cstr_cat(&cstr, s1->cmd_include_files[i], -1); + cstr_cat(&cstr, "\"\n", -1); + } + *s1->include_stack_ptr++ = file; + tcc_open_bf(s1, "", cstr.size); + memcpy(file->buffer, cstr.data, cstr.size); + cstr_free(&cstr); + } } ST_FUNC void tccpp_new(TCCState *s) -- cgit v1.3.1