From 39bd196481ba9ec6f5ef90a5e1b72976a3dc5e35 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 16 May 2016 13:46:33 -0300 Subject: [PATCH] AP_GPS: do not use flexible array in union We actually don't want a flexible array in this union, but rather a way to access it byte by byte. This fixes the build for gcc >= 6 In file included from ../../libraries/AP_GPS/AP_GPS.cpp:24:0: ../../libraries/AP_GPS/AP_GPS_ERB.h:93:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. In file included from ../../libraries/AP_GPS/AP_GPS_ERB.cpp:22:0: ../../libraries/AP_GPS/AP_GPS_ERB.h:93:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. In file included from ../../libraries/AP_GPS/AP_GPS_MTK.cpp:25:0: ../../libraries/AP_GPS/AP_GPS_MTK.h:75:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. In file included from ../../libraries/AP_GPS/AP_GPS_MTK19.cpp:26:0: ../../libraries/AP_GPS/AP_GPS_MTK.h:75:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. In file included from ../../libraries/AP_GPS/AP_GPS_SIRF.cpp:22:0: ../../libraries/AP_GPS/AP_GPS_SIRF.h:101:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. In file included from ../../libraries/AP_GPS/AP_GPS_UBLOX.cpp:23:0: ../../libraries/AP_GPS/AP_GPS_UBLOX.h:387:23: error: flexible array member in union uint8_t bytes[]; ^ compilation terminated due to -Wfatal-errors. --- libraries/AP_GPS/AP_GPS_ERB.h | 2 +- libraries/AP_GPS/AP_GPS_MTK.h | 2 +- libraries/AP_GPS/AP_GPS_MTK19.h | 2 +- libraries/AP_GPS/AP_GPS_SIRF.h | 2 +- libraries/AP_GPS/AP_GPS_UBLOX.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/AP_GPS/AP_GPS_ERB.h b/libraries/AP_GPS/AP_GPS_ERB.h index 8d04697111..5c0c3fc825 100644 --- a/libraries/AP_GPS/AP_GPS_ERB.h +++ b/libraries/AP_GPS/AP_GPS_ERB.h @@ -90,7 +90,7 @@ private: erb_stat stat; erb_dops dops; erb_vel vel; - uint8_t bytes[]; + uint8_t bytes[1]; } _buffer; enum erb_protocol_bytes { diff --git a/libraries/AP_GPS/AP_GPS_MTK.h b/libraries/AP_GPS/AP_GPS_MTK.h index e8ce210e3a..fa2188f125 100644 --- a/libraries/AP_GPS/AP_GPS_MTK.h +++ b/libraries/AP_GPS/AP_GPS_MTK.h @@ -72,7 +72,7 @@ private: // Receive buffer union PACKED { diyd_mtk_msg msg; - uint8_t bytes[]; + uint8_t bytes[1]; } _buffer; // Buffer parse & GPS state update diff --git a/libraries/AP_GPS/AP_GPS_MTK19.h b/libraries/AP_GPS/AP_GPS_MTK19.h index 43b08618a2..054a94c491 100644 --- a/libraries/AP_GPS/AP_GPS_MTK19.h +++ b/libraries/AP_GPS/AP_GPS_MTK19.h @@ -78,6 +78,6 @@ private: // Receive buffer union { diyd_mtk_msg msg; - uint8_t bytes[]; + uint8_t bytes[1]; } _buffer; }; diff --git a/libraries/AP_GPS/AP_GPS_SIRF.h b/libraries/AP_GPS/AP_GPS_SIRF.h index 6c6f74bc90..8833c9ca7f 100644 --- a/libraries/AP_GPS/AP_GPS_SIRF.h +++ b/libraries/AP_GPS/AP_GPS_SIRF.h @@ -98,7 +98,7 @@ private: // Message buffer union { sirf_geonav nav; - uint8_t bytes[]; + uint8_t bytes[1]; } _buffer; bool _parse_gps(void); diff --git a/libraries/AP_GPS/AP_GPS_UBLOX.h b/libraries/AP_GPS/AP_GPS_UBLOX.h index 2ea52abad0..c33316e9f1 100644 --- a/libraries/AP_GPS/AP_GPS_UBLOX.h +++ b/libraries/AP_GPS/AP_GPS_UBLOX.h @@ -384,7 +384,7 @@ private: ubx_rxm_rawx rxm_rawx; #endif ubx_ack_ack ack; - uint8_t bytes[]; + uint8_t bytes[1]; } _buffer; enum ubs_protocol_bytes {