[PATCH] Fix compilation of C++ programs that include <bluetooth/bluetooth.h>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



C++ doesn't allow for implicit conversion from void*.

/usr/include/bluetooth/bluetooth.h: In function ‘uint64_t bt_get_le64(void*)’:
/usr/include/bluetooth/bluetooth.h:131: error: invalid conversion from ‘void*’ to ‘bt_get_le64(void*)::<anonymous struct>*’
/usr/include/bluetooth/bluetooth.h: In function ‘uint64_t bt_get_be64(void*)’:
/usr/include/bluetooth/bluetooth.h:136: error: invalid conversion from ‘void*’ to ‘bt_get_be64(void*)::<anonymous struct>*’
/usr/include/bluetooth/bluetooth.h: In function ‘uint32_t bt_get_le32(void*)’:
/usr/include/bluetooth/bluetooth.h:141: error: invalid conversion from ‘void*’ to ‘bt_get_le32(void*)::<anonymous struct>*’
/usr/include/bluetooth/bluetooth.h: In function ‘uint32_t bt_get_be32(void*)’:
/usr/include/bluetooth/bluetooth.h:146: error: invalid conversion from ‘void*’ to ‘bt_get_be32(void*)::<anonymous struct>*’
/usr/include/bluetooth/bluetooth.h: In function ‘uint16_t bt_get_le16(void*)’:
/usr/include/bluetooth/bluetooth.h:151: error: invalid conversion from ‘void*’ to ‘bt_get_le16(void*)::<anonymous struct>*’
/usr/include/bluetooth/bluetooth.h: In function ‘uint16_t bt_get_be16(void*)’:
/usr/include/bluetooth/bluetooth.h:156: error: invalid conversion from ‘void*’ to ‘bt_get_be16(void*)::<anonymous struct>*’
---
 lib/bluetooth.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 5bd4f03..b4891ef 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -111,17 +111,19 @@ enum {
 /* Bluetooth unaligned access */
 #define bt_get_unaligned(ptr)			\
 ({						\
-	struct __attribute__((packed)) {	\
+	struct __s {				\
 		typeof(*(ptr)) __v;		\
-	} *__p = (void *) (ptr);		\
+	} __attribute__((packed)) ;		\
+	struct __s *__p = (struct __s *) (ptr);	\
 	__p->__v;				\
 })
 
 #define bt_put_unaligned(val, ptr)		\
 do {						\
-	struct __attribute__((packed)) {	\
+	struct __s {				\
 		typeof(*(ptr)) __v;		\
-	} *__p = (void *) (ptr);		\
+	}__attribute__((packed)) ;		\
+	struct __s *__p = (struct __s *) (ptr);	\
 	__p->__v = (val);			\
 } while(0)
 
-- 
on behalf of ST-Ericsson

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux