我正在为移动机器人制作一个 .lib 文件。目前我正在编写一个扫描蓝牙设备的函数。
功能是:
struct Device
{
string DeviceName;
BTH_ADDR DeviceAddress;
};
void ScanForDevices(vector<Device> *Robot)
{
m_bt = BluetoothFindFirstRadio(&m_bt_find_radio, &m_radio);
BluetoothGetRadioInfo(m_radio, &m_bt_info);
m_search_params.hRadio = m_radio;
ZeroMemory(&m_device_info, sizeof(BLUETOOTH_DEVICE_INFO));
m_device_info.dwSize = sizeof(BLUETOOTH_DEVICE_INFO);
m_bt_dev = BluetoothFindFirstDevice(&m_search_params, &m_device_info);
int m_device_id = 0;
char charDeviceName[250];
do {
charDeviceName[250]=NULL;
Robot->push_back(Device());
//WideCharToMultiByte(CP_UTF8,0,m_device_info.szName,-1, charDeviceName,0,NULL, NULL);
WideCharToMultiByte(CP_UTF8,0,m_device_info.szName,-1, charDeviceName,250,NULL, NULL);
Robot[m_device_id]->DeviceName=(string)charDeviceName;
Robot[m_device_id]->DeviceAddress=m_device_info.Address.ullLong;
m_device_id++;
} while(BluetoothFindNextDevice(m_bt_dev,&m_device_info));
BluetoothFindDeviceClose(m_bt_dev);
BluetoothFindRadioClose(m_bt);
}
我不断得到:
Error 6 error C2819: type 'std::vector<_Ty>' does not have an overloaded member 'operator ->'
Error 7 error C2039: 'DeviceName' : is not a member of 'std::vector<_Ty>'
Error 8 error C2819: type 'std::vector<_Ty>' does not have an overloaded member 'operator ->'
Error 9 error C2039: 'DeviceAddress' : is not a member of 'std::vector<_Ty>'
Error 10 IntelliSense: expression must have pointer type
Error 11 IntelliSense: expression must have pointer type
我正在开始使用 C++,但对指针的使用并不十分熟练。
欢迎任何帮助。