linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix compilation of C++ programs that include <bluetooth/bluetooth.h>
@ 2012-01-13  8:18 Szymon Janc
  2012-01-13  8:21 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2012-01-13  8:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: kanak.gupta, Szymon Janc

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix compilation of C++ programs that include <bluetooth/bluetooth.h>
  2012-01-13  8:18 [PATCH] Fix compilation of C++ programs that include <bluetooth/bluetooth.h> Szymon Janc
@ 2012-01-13  8:21 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2012-01-13  8:21 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, kanak.gupta

Hi Szymon,

> 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)
>  

you are messing with powers beyond your control here. I am not touching
this unless a GCC expert guarantees me that it equivalent.

Regards

Marcel



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-13  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13  8:18 [PATCH] Fix compilation of C++ programs that include <bluetooth/bluetooth.h> Szymon Janc
2012-01-13  8:21 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).