我正在尝试在代码块中的raspberry pi B +上编译一个C ++项目。代码取自here
#include <iostream>
#include <cstdint>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
using namespace std;
int main()
{
//cout << "Hello world!" << endl;
inquiry_info *li = NULL;
int max_rsp, num_rsp;
int dev_id, sock, len, flags;
int i;
char addr[19] = {0};
char name[248] = {0};
dev_id = hci_get_route(NULL);
sock = hci_open_dev(dev_id);
if(dev_id < 0||sock < 0)
{
perror("opening socket");
exit(1);
}
len=8;
max_rsp = 255;
flags = IREQ_CACHE_FLUSH;
li = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &li, flags);
if(num_rsp) perror("hci_inquiry");
for(i = 0; i < num_rsp; i++)
{
ba2str(&(li+i)->bdaddr, addr);
memset(name, 0, sizeof(name));
if(hci_read_remote_name(sock, &(li+i)->bdaddr, sizeof(name), name, 0) < 0) strcpy(name, "[unknown]");
printf("%s %s\n", addr, name);
}
free(li);
close(sock);
return 0;
}
带有[std = c ++ 0x]标志的GCC 4.6给出了下一个错误:
/home/pi/bluez-5.11/lib/bluetooth/hci.h|315|error: ‘uint8_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|316|error: ‘uint8_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|317|error: ‘uint8_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|322|error: ‘uint8_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|323|error: ‘bdaddr_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|331|error: ‘uint16_t’ does not name a type|
/home/pi/bluez-5.11/lib/bluetooth/hci.h|332|error: ‘uint16_t’ does not name a type|
如您所见,我有<cstdint>
和using namespace std
行。我做错了什么?