0
我知道有很多關於此問題的問題,但具體而言,我在Ubuntu上實現libusb庫時遇到了問題。 這裏是我的代碼:libusb解引用指向不完整類型的指針
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *digiSpark = NULL;
struct usb_device *device;
if(debug) printf("Detecting USB devices...\n");
// Initialize the USB library
usb_init();
// Enumerate the USB device tree
usb_find_busses();
usb_find_devices();
// Iterate through attached busses and devices
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next)
{
for (device = bus->devices; device; device = device->next)
{
// Check to see if each USB device matches the DigiSpark Vendor and Product IDs
if((device->descriptor.idVendor == 0x16c0) && (device->descriptor.idProduct == 0x05df))
{
if(debug) printf("Detected DigiSpark... \n");
digiSpark = device;
}
}
}
這是採取非常逐字從libusb的例子:
http://libusb.sourceforge.net/doc/examples-code.html
但它產生噸「提領指向不完全類型」的錯誤。
具體來說,我得到這個提領指向不完全類型錯誤以下行:
busses = usb_get_busses();
for (bus = busses; bus; bus->next)
for (device = bus->devices; device; device->next)
以下行
兩次:
if((device->descriptor.idVendor == 0x16c0) && (device->descriptor.idProduct == 0x05df))
正如我所說的,這是奇怪因爲我沒有(大部分)這樣做,這是從lib網站上建立的示例中提取的。
任何建議將是偉大的。謝謝!
表達'device-> next'沒有真正做任何事情。我想你的意思是'device = device-> next'? –
是的,對不起,錯字。所有的錯誤仍然適用。 – eatonphil
而你*包含了定義結構的頭文件? –