0

我正在尝试在代码块中编译树莓派 B+ 上的 C++ 项目。代码取自这里

#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线。我究竟做错了什么?

4

0 回答 0