scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b206061137fe1f86fd9669679e055bc826816f99
parent c30fd72ab5feaa2e1326dbed4feb7ffc581d937e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 25 May 2015 16:50:05 +0200

Implement #undef

Undef only undefined an already defined macro.

Diffstat:
Mcc1/cpp.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -460,8 +460,18 @@ elseclause(char *s) error("#else without #if"); cleanup(s); cppoff += (ifstatus[numif-1] ^= 1) ? -1 : 1; +} - return; +static void +undef(char *s) +{ + Symbol *sym; + + if (!iden(&s)) + error("#undef must have an identifier as parameter"); + sym = lookup(NS_CPP); + sym->flags &= ~ISDEFINED; + cleanup(s); } bool @@ -477,6 +487,7 @@ preprocessor(char *s) "ifndef", ifndef, "endif", endif, "else", elseclause, + "undef", undef, "line", line, "pragma", pragma, "error", usererr,