diff options
| author | 2025-12-06 11:41:44 +0100 | |
|---|---|---|
| committer | 2025-12-06 11:55:41 +0100 | |
| commit | d82f3052c813f671561362126d0fbe08568542d3 (patch) | |
| tree | d82546bdf7f62e3461906c49fa3f3715d13422a6 /main.c | |
| parent | 2054983775165f3ae50b241aae71ccb4969eade4 (diff) | |
add command-line predefined macros (-D, -U)
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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') { |