Powered by Linux
[PATCH 3/8] add predefine_nostd() — Semantic Matching Tool

[PATCH 3/8] add predefine_nostd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>

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@xxxxxxxxx>
Signed-off-by: John Levon <john.levon@xxxxxxxxxx>
---
 lib.h         | 1 +
 pre-process.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/lib.h b/lib.h
index 44e2b5c5..70b2ba39 100644
--- a/lib.h
+++ b/lib.h
@@ -134,6 +134,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 c35cbcfb..5a9313a3 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1568,6 +1568,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;
-- 
2.23.0




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux