From 284df649ad101ae3866ff5f177cabf10fdb66bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Thu, 11 Jan 2018 17:37:03 +0100 Subject: [PATCH 1/2] bluetooth: Fix "struct bt_gatt_read_params" declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling this declaration with a CXX compiler triggers the compiler error: /home/sebo/zephyr/include/bluetooth/gatt.h:898:10: error: ‘struct bt_gatt_read_params::::__single’ invalid; an anonymous union can only have non-static data members [-fpermissive] Reading up on the standard, I was unable to find any mention of this being valid C or CXX code (But reading the standard is not straightforward). And I was unable to find any mechanism to make the CXX compiler accept it (e.g. Changing the -std, or adding this as a language extension e.g. -fms-extensions). So we rewrite it to not declare the struct with the tag "__single". There does not seem to be any reason for it to be declared like this. Signed-off-by: Sebastian Bøe --- include/bluetooth/gatt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bluetooth/gatt.h b/include/bluetooth/gatt.h index 62fc49617b5fc..55fb59b779e3b 100644 --- a/include/bluetooth/gatt.h +++ b/include/bluetooth/gatt.h @@ -895,7 +895,7 @@ struct bt_gatt_read_params { bt_gatt_read_func_t func; size_t handle_count; union { - struct __single { + struct { u16_t handle; u16_t offset; } single; From 7110098ea104b74197a39aa5d3c7100588c89ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Thu, 11 Jan 2018 17:53:45 +0100 Subject: [PATCH 2/2] bluetooth: Fix cast in bt_buf_get_type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function returns an enum, not a u8_t, so we should cast appropriately to avoid an implicit conversion. This construct was triggering this compilation error when compiling with CXX: /home/sebo/zephyr/include/bluetooth/buf.h:85:9: error: invalid conversion from ‘u8_t {aka unsigned char}’ to ‘bt_buf_type’ [-fpermissive] return *(u8_t *)net_buf_user_data(buf); Signed-off-by: Sebastian Bøe --- include/bluetooth/buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h index d02cf69914cd3..11113ee903aaf 100644 --- a/include/bluetooth/buf.h +++ b/include/bluetooth/buf.h @@ -82,7 +82,7 @@ static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type) */ static inline enum bt_buf_type bt_buf_get_type(struct net_buf *buf) { - return *(u8_t *)net_buf_user_data(buf); + return *((enum bt_buf_type *)net_buf_user_data(buf)); } /**