All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bluetooth.h: fix compile issue when using in C++
@ 2012-01-16 10:11 Patrick Ohly
  2012-03-04 23:27 ` Marcel Holtmann
  0 siblings, 1 reply; 18+ messages in thread
From: Patrick Ohly @ 2012-01-16 10:11 UTC (permalink / raw)
  To: linux-bluetooth

The compiler error is:
 /usr/include/bluetooth/bluetooth.h::131:9: error: invalid conversion from 'void*' to 'bt_get_le64(void*)::<anonymous struct>*'
 ...

The reason is that C++, in contrast to C, does not allow conversion of
void * to anything, and this code gets compiled as C++ when the app is
written in C++. The macro with the assignment itself is older, but only
recent Bluez starts to use it in inline functions, thus triggering the
problem.

This patch keeps the "struct __attribute__((packed))" magic and merely
changes the typecast so that it works in C and C++. Like the existing
macro this patch relies on support for typeof.
---
 lib/bluetooth.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 5bd4f03..2fee4ac 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -113,7 +113,7 @@ enum {
 ({						\
 	struct __attribute__((packed)) {	\
 		typeof(*(ptr)) __v;		\
-	} *__p = (void *) (ptr);		\
+	} *__p = (typeof(__p)) (ptr);		\
 	__p->__v;				\
 })
 
@@ -121,7 +121,7 @@ enum {
 do {						\
 	struct __attribute__((packed)) {	\
 		typeof(*(ptr)) __v;		\
-	} *__p = (void *) (ptr);		\
+	} *__p = (typeof(__p)) (ptr);		\
 	__p->__v = (val);			\
 } while(0)
 
-- 
1.7.7.3



^ permalink raw reply related	[flat|nested] 18+ messages in thread
* Re: [PATCH] bluetooth.h: fix compile issue when using in C++
@ 2012-03-03 17:15 Markus Rathgeb
  0 siblings, 0 replies; 18+ messages in thread
From: Markus Rathgeb @ 2012-03-03 17:15 UTC (permalink / raw)
  To: linux-bluetooth

Hello!

The patch "http://www.spinics.net/lists/linux-bluetooth/msg20220.html"
is using the typeof keyword.
I also found the statement:
"I was uncomfortable to depend on "typeof" for that initially, but the
macro already uses that for the struct member."

IMHO typeof is not part of the C++ standard, and isn't available when
we use -std=c++0x.
g++ should support __typeof__ even with -std=c++0x.

So perhaps we could change the C++ "workaround" to use __typeof__
instead of typeof to support also programs that are using c++0x
standard.

^ permalink raw reply	[flat|nested] 18+ messages in thread
* bluetooth.h: fix compile issue when using in C++
@ 2012-07-29  7:52 Pacho Ramos
  2012-08-01 14:41 ` Pacho Ramos
  0 siblings, 1 reply; 18+ messages in thread
From: Pacho Ramos @ 2012-07-29  7:52 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 314 bytes --]

Hello

Today I got a report downstream showing that old problem:
http://permalink.gmane.org/gmane.linux.bluez.kernel/22306

is still not fixed. 

Could you please commit debian patch to fix this?
http://patch-tracker.debian.org/patch/series/view/bluez/4.101-1/09_fix_ftbfs_with_c99.patch

Thanks  a lot

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2012-09-05 17:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16 10:11 [PATCH] bluetooth.h: fix compile issue when using in C++ Patrick Ohly
2012-03-04 23:27 ` Marcel Holtmann
2012-03-05  7:33   ` Patrick Ohly
     [not found]     ` <CAOcK=CNZofxZtUp4Zh5eiGMM_TYrbGOwseA3tcwAnAFDvLEFxg@mail.gmail.com>
2012-03-05 13:12       ` Patrick Ohly
2012-03-05 14:53         ` Markus Rathgeb
2012-07-27 16:38         ` W. Trevor King
2012-08-17  5:18         ` W. Trevor King
2012-08-27 23:40           ` Johan Hedberg
2012-09-05 17:27             ` Pacho Ramos
2012-09-05 17:56               ` Pacho Ramos
2012-03-05 20:06   ` Lucas De Marchi
2012-03-08 13:22     ` Markus Rathgeb
2012-03-08 17:51       ` Marcel Holtmann
2012-03-08 20:59         ` Markus Rathgeb
2012-03-09 10:52           ` Markus Rathgeb
2012-03-03 17:15 Markus Rathgeb
2012-07-29  7:52 Pacho Ramos
2012-08-01 14:41 ` Pacho Ramos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.