Skip to contentSkip to conversation

inline keyword & ansi-C compilers

PATCH In review [email protected] 2 participants 4 messages Jul 31, 2006 – Aug 2, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inline keyword & ansi-C compilers

Hi

Recently when I`ve tried to compile KDE (ktnef to be exact) I came upon an error in your include files:

configure:34044: result: /usr/bin/doxygen
configure:34133: checking bluetooth/bluetooth.h usability
configure:34145:
i686-pc-linux-gnu-gcc -c -std=iso9899:1990 -W -Wall -Wchar-subscripts -Wshadow -Wpointer-arith -Wmissing-prototypes
-Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -DNDEBUG -O2 -O2 -march=k6 -mtune=athlon-xp -pipe -Wformat-security -Wmissing-fo
rmat-attribute -DQT_THREAD_SUPPORT -D_REENTRANT conftest.c >&5
In file included from conftest.c:101:
/usr/include/bluetooth/bluetooth.h:113: error:
expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/bluetooth/bluetooth.h:117: error:
expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
configure:34151: $? = 1

After checking the header file it became clear that the 'inline' keyword is responsible for the mess. As you can see ./configure is executing gcc with -std=iso9899:1990 flag which sets the language dialect to pure C89. Unfortunately this dialect doesn`t support the 'inline' keyword. To reproduce this bug try:

thermal@newhope ~ $ cat > a.c
#include <bluetooth.h>
thermal@newhope ~ $ gcc -std=iso9899:1990 -c -I ~/bluez-libs-3.2/include a.c
In file included from a.c:1:
/home/thermal/bluez-libs-3.2/include/bluetooth.h:113: error:
expected '=', ',', ';', 'asm' or '__attribute__' before 'int' /home/thermal/bluez-libs-3.2/include/bluetooth.h:117: error:
expected '=', ',', ';', 'asm' or '__attribute__' before 'void' thermal@newhope ~ $

So I wrote a tiny patch to fix this:

--- bluez-libs-3.2/include/bluetooth.h 2006-07-31 20:57:08.000000000 +0200
+++ /usr/include/bluetooth/bluetooth.h 2006-07-31 20:55:55.000000000 +0200
@@ -109,12 +109,19 @@
#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff,
0xff}})
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})

+/* No inline keyword in the iso8988:1990 standard */ +#ifdef __STRICT_ANSI__
+ #define __INLINE
+#else
+ #define __INLINE inline
+#endif
+
/* Copy, swap, convert BD Address */
-static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) +static __INLINE int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)

 {
        return memcmp(ba1, ba2, sizeof(bdaddr_t));
 }
-static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
+static __INLINE void bacpy(bdaddr_t *dst, const bdaddr_t *src)
 {
        memcpy(dst, src, sizeof(bdaddr_t));

}

After applying it all compiles nicely:

thermal@newhope ~ $ cat > a.c
#include <bluetooth/bluetooth.h>
thermal@newhope ~ $ gcc -std=iso9899:1990 -c a.c
thermal@newhope ~ $

(Note: my patched header file lives in /usr/inlude/bluetooth). It would be nice if the patch was included in the main source.

Signature · 13 lines
|   ******* Maciek Grela RV409b *********
|        JID: [email protected]
| Linux user #319794 ++ There is no spoon ...

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#1 lore raw

Hi,

Quoted 2 lines

Recently when I`ve tried to compile KDE (ktnef to be exact) I came upon an error in your include files:

no idea what ktnef has to do with BlueZ. This seems to be the main problem here.

Quoted 8 lines

So I wrote a tiny patch to fix this:

--- bluez-libs-3.2/include/bluetooth.h 2006-07-31 20:57:08.000000000 +0200
+++ /usr/include/bluetooth/bluetooth.h 2006-07-31 20:55:55.000000000 +0200

(quoted diff) +0 -0
@@ -109,12 +109,19 @@
 #define BDADDR_ALL   (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 

Review line 119

Quoted 10 lines
(quoted diff) +7 -0
 0xff}})
 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
 
+/* No inline keyword in the iso8988:1990 standard */
+#ifdef __STRICT_ANSI__
+    #define __INLINE
+#else
+    #define __INLINE inline
+#endif
+

I don't like to provide any workarounds for any crazy standard that forcing it makes no real sense to me. However what about this:

#ifdef __STRICT_ANSI__
#define inline
#endif

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
Quoted 8 lines · Marcel Holtmann

Hi,

Quoted 2 lines

Recently when I`ve tried to compile KDE (ktnef to be exact) I came upon an error in your include files:

no idea what ktnef has to do with BlueZ. This seems to be the main problem here.

Yes, this may look a bit weird but ktnef is a part of the kdepim source bundle which contains addressbook, organizer, etc. and thus can make use of Bluetooth.

Quoted 5 lines

#ifdef __STRICT_ANSI__
#define inline
#endif

You`re right, that will be much better.

Signature · 13 lines
|   ******* Maciek Grela RV409b *********
|        JID: [email protected]
| Linux user #319794 ++ There is no spoon ...

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#3 lore raw

Hi,

Quoted 12 lines
Quoted 6 lines
Quoted 2 lines

Recently when I`ve tried to compile KDE (ktnef to be exact) I came upon an error in your include files:

no idea what ktnef has to do with BlueZ. This seems to be the main problem here.

Yes, this may look a bit weird but ktnef is a part of the kdepim source bundle which contains addressbook, organizer, etc. and thus can make use of Bluetooth.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines

#ifdef __STRICT_ANSI__
#define inline
#endif

You`re right, that will be much better.

and why not including this into the ktnef source. I personally don't like this hack to be in bluez-libs.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel