[rtems commit] score: Add and use RTEMS_ZERO_LENGTH_ARRAY

Sebastian Huber sebh at rtems.org
Tue Apr 15 09:08:29 UTC 2014


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Apr 14 12:41:57 2014 +0200

score: Add and use RTEMS_ZERO_LENGTH_ARRAY

---

 cpukit/libblock/include/rtems/blkdev.h         |    2 +-
 cpukit/libblock/include/rtems/ide_part_table.h |    2 +-
 cpukit/score/include/rtems/score/basedefs.h    |    7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index f934871..d17cadc 100644
--- a/cpukit/libblock/include/rtems/blkdev.h
+++ b/cpukit/libblock/include/rtems/blkdev.h
@@ -142,7 +142,7 @@ typedef struct rtems_blkdev_request {
   /**
    * List of scatter or gather buffers.
    */
-  rtems_blkdev_sg_buffer bufs[0];
+  rtems_blkdev_sg_buffer bufs[RTEMS_ZERO_LENGTH_ARRAY];
 } rtems_blkdev_request;
 
 /**
diff --git a/cpukit/libblock/include/rtems/ide_part_table.h b/cpukit/libblock/include/rtems/ide_part_table.h
index 3b4b8a5..261135c 100644
--- a/cpukit/libblock/include/rtems/ide_part_table.h
+++ b/cpukit/libblock/include/rtems/ide_part_table.h
@@ -78,7 +78,7 @@
 typedef struct rtems_sector_data_s
 {
     uint32_t   sector_num; /* sector number on the device */
-    uint8_t    data[0]; /* raw sector data */
+    uint8_t    data[RTEMS_ZERO_LENGTH_ARRAY]; /* raw sector data */
 } rtems_sector_data_t;
 
 
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index c6f639b..a0bebdd 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -208,6 +208,13 @@
 
 #define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
 
+/*
+ * Zero-length arrays are valid in C99 as flexible array members.  C++11
+ * doesn't allow flexible array members.  Use the GNU extension which is also
+ * supported by other compilers.
+ */
+#define RTEMS_ZERO_LENGTH_ARRAY 0
+
 #ifndef ASM
   #ifdef RTEMS_DEPRECATED_TYPES
     typedef bool boolean;




More information about the vc mailing list