[rtems commit] score: Use flexible-array member for C99 and later

Sebastian Huber sebh at rtems.org
Tue Aug 4 13:48:54 UTC 2020


Module:    rtems
Branch:    master
Commit:    2ae557eb04347d3e355b696192f7b7c48472befa
Changeset: http://git.rtems.org/rtems/commit/?id=2ae557eb04347d3e355b696192f7b7c48472befa

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Aug  3 10:25:53 2020 +0200

score: Use flexible-array member for C99 and later

This addresses compiler warnings like this:

warning: array subscript 0 is outside the bounds of an interior
zero-length array 'abc[0]' [-Wzero-length-bounds]

---

 cpukit/include/rtems/score/basedefs.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h
index a934507..5a7e4e4 100644
--- a/cpukit/include/rtems/score/basedefs.h
+++ b/cpukit/include/rtems/score/basedefs.h
@@ -430,7 +430,11 @@
  * doesn't allow flexible array members.  Use the GNU extension which is also
  * supported by other compilers.
  */
-#define RTEMS_ZERO_LENGTH_ARRAY 0
+#if __STDC_VERSION__ >= 199409L
+  #define RTEMS_ZERO_LENGTH_ARRAY
+#else
+  #define RTEMS_ZERO_LENGTH_ARRAY 0
+#endif
 
 /**
  * @brief Returns a pointer to the container of a specified member pointer.



More information about the vc mailing list