最近用ads,因为涉及到usb驱动,所以需要使用关键字__packed,但是用这个后会出现错误。阅读了ads
的相关的文档,有是有介绍__packed的用法,但我按照这样写后还是有问题。希望哪位能帮助我下,非常
感谢!
下面是代码: /* Device descriptor */ typedef __packed struct usb_device_descriptor { INT8U bLength; INT8U bDescriptorType; INT16U bcdUSB; INT8U bDeviceClass; INT8U bDeviceSubClass; INT8U bDeviceProtocol; INT8U bMaxPacketSize0; INT16U idVendor; INT16U idProduct; INT16U bcdDevice; INT8U iManufacturer; INT8U iProduct; INT8U iSerialNumber; INT8U bNumConfigurations; } USB_DEV_DESC_T;
INT32S usb_reset_device(USB_DEV_T *dev){ ...... struct usb_device_descriptor *descriptor; ...... descriptor = (struct usb_device_descriptor *)malloc(sizeof *descriptor); ...... free(descriptor); ...... } 按照ads的提示,错误出现在free(descriptor)这里。具体的错误提示是: Error:C2906E:<argument 1 to 'free'>:implicit cast of pointer loses '__packed' qualifier 哪位帮看下。3ks先。
|