基于bluez or socketcan等 程序编译时注意事项

本文介绍了基于Bluez程序编译时的两个关键注意事项:首先,确保所有必要的头文件都被正确包含,特别是首要包含bluetooth/bluetooth.h;其次,在包含蓝牙头文件前,必须先引入socket头文件以避免编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于bluez程序编译时注意事项                                 

 

第一:不要用到哪个Bluez头文件中定义的内容就只去包含这个头文件。而应该将bluetooth/bluetooth.h最先加入。类似:
//==================================
//bluetooth header file
#include <bluetooth/bluetooth.h> //BTPROTO_HCI
#include <bluetooth/hci.h>          //struct hci_dev_info
#include <bluetooth/hci_lib.h>     //hci_devid()
#include <bluetooth/l2cap.h>      //l2cap
#include <bluetooth/hidp.h>       //hidp


第二:因为Linux 下Bluetooth实现是通过socket来完成的。sa_family_t会被使用。
bluetooth/hci.h中就用到了。所以必须在include bluetooth header file之前,include socket header file.
#include <sys/types.h> 
#include <sys/socket.h>
否则就会出现类似以下问题:
bluetooth/hci.h:1091: error: expected specifier-qualifier-list before 'sa_family_t'
  以上亦可用到socketcan中
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值