[PATCH 1/4] Only enable -Wmissing-field-initializers for Clang

Lubomir I. Ivanov neolit123 at gmail.com
Sat Mar 11 12:08:31 PST 2017


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

The following pragma is Clang specific:

It produces a warning:
warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]

Only enable it for Clang by checking the __clang__ macro.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 core/cochran.c         | 2 ++
 core/datatrak.c        | 2 ++
 core/equipment.c       | 2 ++
 core/git-access.c      | 2 ++
 core/libdivecomputer.c | 2 ++
 core/load-git.c        | 2 ++
 core/membuffer.c       | 2 ++
 core/parse-xml.c       | 2 ++
 core/save-git.c        | 2 ++
 core/save-html.c       | 2 ++
 core/save-xml.c        | 2 ++
 core/worldmap-save.c   | 2 ++
 12 files changed, 24 insertions(+)

diff --git a/core/cochran.c b/core/cochran.c
index c31e78f..430c3b4 100644
--- a/core/cochran.c
+++ b/core/cochran.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/core/datatrak.c b/core/datatrak.c
index 6c9b007..272aa34 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/core/equipment.c b/core/equipment.c
index 0d4ab55..19b50ab 100644
--- a/core/equipment.c
+++ b/core/equipment.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 /* equipment.c */
 #include <stdio.h>
diff --git a/core/git-access.c b/core/git-access.c
index b95606d..ac4ac80 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index 8ffb49d..f8f9823 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <unistd.h>
diff --git a/core/load-git.c b/core/load-git.c
index 03e7f86..fdac2ef 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/core/membuffer.c b/core/membuffer.c
index 053edb8..e35f160 100644
--- a/core/membuffer.c
+++ b/core/membuffer.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 38cd25f..2f5be06 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/core/save-git.c b/core/save-git.c
index d0ae790..cfcd362 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/core/save-html.c b/core/save-html.c
index 0b2d8e7..2824625 100644
--- a/core/save-html.c
+++ b/core/save-html.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include "save-html.h"
 #include "qthelperfromc.h"
diff --git a/core/save-xml.c b/core/save-xml.c
index c9b6a5b..b6a0e4b 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/core/worldmap-save.c b/core/worldmap-save.c
index e7e8bcc..8ad6535 100644
--- a/core/worldmap-save.c
+++ b/core/worldmap-save.c
@@ -1,5 +1,7 @@
+#ifdef __clang__
 // Clang has a bug on zero-initialization of C structs.
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 #include <stdarg.h>
 #include <stdlib.h>
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list