scc

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

commit 766c342d4a6d02f37a9f66c75a696530a36cdc24
parent 2d77075828c480d5cb0ad3ddb40199ccbbcc27b1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Jul 2015 09:22:59 +0200

Create a list of flag macros

We will have to create more of this macros that are used as
flags, so it is better to have a list and a loop over them.

Diffstat:
Mcc1/cpp.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -40,20 +40,26 @@ icpp(void) static char sdate[17], stime[14]; struct tm *tm; time_t t; + char **bp, *list[] = { + "__STDC__", + "__STDC_HOSTED__", + "__SCC__", + NULL + }; t = time(NULL); tm = localtime(&t); strftime(sdate, sizeof(sdate), "-1#\"%b %d %Y\"", tm); strftime(stime, sizeof(stime), "-1#\"%H:%M:%S\"", tm); - - defmacro("__STDC__")->u.s = "-1#1"; - defmacro("__SCC__")->u.s = "-1#1"; defmacro("__DATE__")->u.s = sdate; defmacro("__TIME__")->u.s = stime; - defmacro("__STDC_HOSTED__")->u.s = "-1#1"; + defmacro("__STDC_VERSION__")->u.s = "-1#199409L"; symline = defmacro("__LINE__"); symfile = defmacro("__FILE__"); + + for (bp = list; *bp; ++bp) + defmacro(*bp)->u.s = "-1#1"; } static void