Can a C++11 program use BlueZ?

筅森魡賤 提交于 2019-12-11 10:16:26

问题


I am having trouble compiling a simple C++11 program using the BlueZ library :

#include <bluetooth/bluetooth.h>
int main() {}

Compiling this with g++ -std=c++11 main.cpp on my Fedora 21 box gives :

In file included from ../scale.cpp:1:0:
/usr/include/bluetooth/bluetooth.h: In function ‘uint64_t bt_get_le64(const void*)’:
/usr/include/bluetooth/bluetooth.h:177:9: error: expected identifier before ‘*’ token
  return bt_get_unaligned((const uint64_t *) ptr);
         ^
...

This is with BlueZ version 5.23 and GCC 4.9.2. Everything works if I remove the -std=c++11 flag.

Is this normal?


回答1:


By default GCC compiles to C++03 with GNU extensions. If you specify -std=C++11 then it compiles to ISO C++11 with no extensions enabled. However if you specify -std=gnu++11 instead then you also get the GNU extensions.




回答2:


There is an issue in bluetooth.h, just replace typeof with __typeof__ and this will be fixed, here's a reference: http://git.kernel.org/cgit/bluetooth/bluez.git/commit/lib/bluetooth.h?id=cf52a40302d0d20ccca22a7a1f53e46ef8abfca8



来源:https://stackoverflow.com/questions/27925454/can-a-c11-program-use-bluez

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!