From 00cace12abeda718c3dfc3425c4e45f367094375 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Tue, 21 Jan 2020 00:39:17 +0100 Subject: add predefine_nostd() GCC adds predefines for some symbols lying in the user's namespace, like "linux" or "sparc", but only if the selected dialect is not one of the standard ones. Add an helper, predefine_nostd(), for these. Signed-off-by: Luc Van Oostenryck --- lib.h | 1 + pre-process.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib.h b/lib.h index 23623525..72651cef 100644 --- a/lib.h +++ b/lib.h @@ -135,6 +135,7 @@ enum phase { extern void add_pre_buffer(const char *fmt, ...) FORMAT_ATTR(1); extern void predefine(const char *name, int weak, const char *fmt, ...) FORMAT_ATTR(3); +extern void predefine_nostd(const char *name); extern int preprocess_only; diff --git a/pre-process.c b/pre-process.c index ca92ff06..7b245a04 100644 --- a/pre-process.c +++ b/pre-process.c @@ -1434,6 +1434,14 @@ void predefine(const char *name, int weak, const char *fmt, ...) do_define(value->pos, NULL, ident, NULL, value, attr); } +/// +// like predefine() but only if one of the non-standard dialect is chosen +void predefine_nostd(const char *name) +{ + if ((standard & STANDARD_GNU) || (standard == STANDARD_NONE)) + predefine(name, 1, "1"); +} + static int do_handle_define(struct stream *stream, struct token **line, struct token *token, int attr) { struct token *arglist, *expansion; -- cgit 1.2.3-korg