C++11程序可以使用BlueZ吗?
Can a C++11 program use BlueZ?
我在使用 BlueZ 库编译一个简单的 C++11 程序时遇到问题:
#include <bluetooth/bluetooth.h>
int main() {}
在我的 Fedora 21 盒子上用g++ -std=c++11 main.cpp
编译它得到:
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);
^
...
这是BlueZ版本5.23和GCC 4.9.2。如果我删除-std=c++11
标志,一切正常。
这正常吗?
默认情况下,GCC 使用 GNU 扩展编译为 C++03。如果指定-std=C++11
则它将编译为 ISO C++11,而不启用扩展名。但是,如果您指定-std=gnu++11
,那么您也将获得 GNU 扩展。
蓝牙.h中存在问题,只需将typeof
替换为__typeof__
即可修复,这里有一个参考:http://git.kernel.org/cgit/bluetooth/bluez.git/commit/lib/bluetooth.h?id=cf52a40302d0d20ccca22a7a1f53e46ef8abfca8
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++,系统无法执行指定的程序
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 重载操作程序时出错>>用于类中的字符串 memebr
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 试图在visual studio上用C++创建一个桌面应用程序
- 模板元程序查找相似的连续类型名称
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 如何通过cpp程序运行shell脚本
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- IPC使用多个管道和分支进程来运行Python程序
- 如何将c++程序的一些输出传递给shell,以便在shell中使用
- 使用C++程序合并排序没有得到正确的输出
- 基于boost的程序的静态链接——zlib问题
- 程序崩溃并显示"std::out_of_range"错误
- 在C应用程序中运行C++(带有STL)函数
- 使用mongocxx驱动程序时包含头文件问题
- C++11程序可以使用BlueZ吗?