summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-05-03 15:38:05 -0700
committerCommit Bot <commit-bot@chromium.org>2021-08-28 01:11:51 +0000
commit0809cdaa2b9ce42524dfa3811204c36a14fc813f (patch)
treea617d0cbc0f808e698833a8a21699c9dc62dd88d /util
parent3af7ccf34aa5ddcd9c2e9fefdd028fe758714fff (diff)
downloadchrome-ec-0809cdaa2b9ce42524dfa3811204c36a14fc813f.tar.gz
util: Avoid redefining _GNU_SOURCE
When compiling with C++ _GNU_SOURCE is already defined, which generates a compiler error: util/comm-i2c.cc:6:9: error: '_GNU_SOURCE' macro redefined [-Werror,-Wmacro-redefined] ^ <built-in>:393:9: note: previous definition is here ^ For details on why g++ always defines _GNU_SOURCE on Linux see https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: If7c2f241562a093d4acf32ccccdf247092458fdd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2869429 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/comm-i2c.c2
-rw-r--r--util/uut/opr.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/util/comm-i2c.c b/util/comm-i2c.c
index 83e0b1dcf7..d76749fbe5 100644
--- a/util/comm-i2c.c
+++ b/util/comm-i2c.c
@@ -3,7 +3,9 @@
* found in the LICENSE file.
*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for asprintf */
+#endif
#include <errno.h>
#include <fcntl.h>
diff --git a/util/uut/opr.c b/util/uut/opr.c
index 2b53cafd54..2105a199a1 100644
--- a/util/uut/opr.c
+++ b/util/uut/opr.c
@@ -5,7 +5,11 @@
*/
/* This file implements the UART console application operations. */
-#define _GNU_SOURCE
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE /* for asprintf */
+#endif
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>