[PATCH] build: Fix duplicated macros when building with CFLAGS="-std=c11 -D_GNU_SOURCE"

thomasanderson at chromium.org thomasanderson at chromium.org
Tue Jul 31 23:21:50 UTC 2018


From: Tom Anderson <thomasanderson at chromium.org>

Fixes errors of the form:
error: '_GNU_SOURCE' macro redefined [-Werror,-Wmacro-redefined]
---
 cursor/os-compatibility.c | 2 ++
 src/connection.c          | 2 ++
 src/wayland-client.c      | 2 ++
 src/wayland-os.c          | 2 ++
 src/wayland-server.c      | 2 ++
 src/wayland-shm.c         | 2 ++
 tests/os-wrappers-test.c  | 2 ++
 tests/test-runner.c       | 2 ++
 8 files changed, 16 insertions(+)

diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c
index e972d21..b676617 100644
--- a/cursor/os-compatibility.c
+++ b/cursor/os-compatibility.c
@@ -23,7 +23,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/src/connection.c b/src/connection.c
index 294c521..f5812a2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -24,7 +24,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <math.h>
 #include <stdlib.h>
diff --git a/src/wayland-client.c b/src/wayland-client.c
index 0ccfc66..3f980f3 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -24,7 +24,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/src/wayland-os.c b/src/wayland-os.c
index 93b6f5f..ab34b38 100644
--- a/src/wayland-os.c
+++ b/src/wayland-os.c
@@ -23,7 +23,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <sys/types.h>
 #include <sys/socket.h>
diff --git a/src/wayland-server.c b/src/wayland-server.c
index eae8d2e..c3962b1 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -23,7 +23,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index 4191231..59a34fc 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -28,7 +28,9 @@
  *
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/tests/os-wrappers-test.c b/tests/os-wrappers-test.c
index 102622c..5f63aaa 100644
--- a/tests/os-wrappers-test.c
+++ b/tests/os-wrappers-test.c
@@ -24,7 +24,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <stdlib.h>
 #include <stdint.h>
diff --git a/tests/test-runner.c b/tests/test-runner.c
index 82a0a7b..68ae1ac 100644
--- a/tests/test-runner.c
+++ b/tests/test-runner.c
@@ -23,7 +23,9 @@
  * SOFTWARE.
  */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <unistd.h>
 #include <stdio.h>
-- 
2.18.0.345.g5c9ce644c3-goog



More information about the wayland-devel mailing list