From d82f3052c813f671561362126d0fbe08568542d3 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 6 Dec 2025 11:41:44 +0100 Subject: add command-line predefined macros (-D, -U) --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 4b904a0..ac45cc5 100644 --- a/main.c +++ b/main.c @@ -179,8 +179,11 @@ optparse(char **args) } } else if (*arg == 'g') { /* TODO debug info */ - } else if (*arg == 'D') { - /* TODO cmdline defines */ + } else if (*arg == 'D' || *arg == 'U') { + void cpppredef(bool undef, const char *cmd); + const char *def = arg[1] ? arg+1 : *++args; + if (!def) fatal(NULL, "macro name missing after `-%c`", *arg); + cpppredef(*arg == 'U', def); } else if (*arg == 'O') { /* TODO optimization level */ } else if (*arg == 'I') { -- cgit v1.2.3