From e946eb2a4109e0de5f8514457f851897a4824c3e Mon Sep 17 00:00:00 2001 From: Vlad Vissoultchev Date: Wed, 6 Apr 2016 18:57:11 +0300 Subject: Implement -dM preprocessor option as in gcc There was already support for -dD option but in contrast -dM dumps only `#define` directives w/o actual preprocessor output. The original -dD output differs from gcc output by additional comment in front of `#define`s so this quirk is left for -dM as well. --- libtcc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libtcc.c') diff --git a/libtcc.c b/libtcc.c index 8fd8183..7b232a2 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1225,6 +1225,8 @@ LIBTCCAPI void tcc_delete(TCCState *s1) /* close a preprocessor output */ if (s1->ppfp && s1->ppfp != stdout) fclose(s1->ppfp); + if (s1->dffp && s1->dffp != s1->ppfp) + fclose(s1->dffp); /* free all sections */ for(i = 1; i < s1->nb_sections; i++) @@ -2175,8 +2177,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) s->output_type = TCC_OUTPUT_OBJ; break; case TCC_OPTION_d: - if (*optarg == 'D') - s->dflag = 1; + if (*optarg == 'D' || *optarg == 'M') + s->dflag = *optarg; else { if (s->warn_unsupported) goto unsupported_option; -- cgit v1.3.1