summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-09-13 13:06:14 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-16 23:09:16 +0000
commit83790c8b685bff4c9bed07a20f9eb9eb1e7b7255 (patch)
treeebe96b6e5956372682bed648cbb9207a1ba88420
parent68822db5f053e0120bfcb16ef2aa7ea70e36727c (diff)
downloadchrome-ec-83790c8b685bff4c9bed07a20f9eb9eb1e7b7255.tar.gz
ec_commands: Fix flexible array member with g++
g++ gives an error when using a flexible array member as the only member of a struct, but works with the zero-length array extension. BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I89775cef72cd0adaa77c8b4f281ed0327696d4f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3894404 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--include/ec_commands.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 4fbcb6626c..a4ec6a00ed 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -76,12 +76,12 @@ extern "C" {
/**
* Constant for creation of flexible array members that work in both C and
* C++. Flexible array members were added in C99 and are not part of the C++
- * standard. However, clang++ and g++ support them in C++.
- * When compiling C code, flexible array members are not allowed to appear
+ * standard. However, clang++ supports them for C++.
+ * When compiling with gcc, flexible array members are not allowed to appear
* in an otherwise empty struct, so we use the GCC zero-length array
- * extension that works with both clang and gcc.
+ * extension that works with both clang/gcc/g++.
*/
-#ifdef __cplusplus
+#if defined(__cplusplus) && defined(__clang__)
#define FLEXIBLE_ARRAY_MEMBER_SIZE
#else
#define FLEXIBLE_ARRAY_MEMBER_SIZE 0