diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-01-21 00:39:17 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-01-22 23:24:07 +0100 |
commit | 00cace12abeda718c3dfc3425c4e45f367094375 (patch) | |
tree | 7a3b77c60af7d04d1b27ec5f09aebd6c2dc69b9a | |
parent | eed8930cb4ec54047c584afd30f2ac53ff2c3317 (diff) | |
download | sparse-00cace12abeda718c3dfc3425c4e45f367094375.tar.gz |
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 <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.h | 1 | ||||
-rw-r--r-- | pre-process.c | 8 |
2 files changed, 9 insertions, 0 deletions
@@ -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; |