【发布时间】:2020-10-15 14:15:04
【问题描述】:
我正在使用运行良好的库 libusb,但现在我正尝试在我自己的结构中使用它的结构。我认为问题只是我复制结构的方式,所以可能不需要了解 libusb 的工作原理。 我的结构包含 libusb 结构:
struct device {
libusb_device *device_handled;
libusb_device_handle *handle;
int port[7];
};
typedef struct device device;
和我的功能:
int myfunction(device *device_element)
{
libusb_device *tempdevice;
libusb_device_handle *temphandle;
device_element = malloc(sizeof(device));
//my code here where I use tempdevice and temphandle
(&device_element)->device_handled = tempdevice;
(&device_element)->handle = temphandle;
}
发出的错误来自最后两行,我不太明白为什么。
‘device_element’ is a pointer; did you mean to use ‘->’?
(&device_element)->handle = temphandle;
^~
->
【问题讨论】: