C语言void*和*p的使用
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <time.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <signal.h> #include <string.h> #include <stdlib.h> #define USB_CLASS_VIDEO 0x0e #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03 #define UVC_INTF_VIDEO_CONTROL 0 #define USB_DT_INTERFACE_ASSOCIATION 0x0b typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ struct usb_interface_assoc_descriptor { __u8 bLength; __u8 bDescriptorType; __u8 bFirstInterface; __u8 bInterfaceCount; __u8 bFunctionClass; __u8 bFunctionSubClass; __u8 bFunctionProtocol; __u8 iFunction; } __attribute__ ((packed)); static struct usb_interface_assoc_descriptor uvc_iad = { .bLength = sizeof(uvc_iad), .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, .bFirstInterface = 0, .bInterfaceCount = 2, .bFunctionClass = USB_CLASS_VIDEO, .bFunctionSubClass = UVC_SC_VIDEO_INTERFACE_COLLECTION, .bFunctionProtocol = 0x00, .iFunction = 0, }; //0-8 ? int main() { struct usb_interface_assoc_descriptor* puvc_iad = NULL; puvc_iad = &uvc_iad; printf(" sizeof %d \n",sizeof(*puvc_iad)); printf("p is sizeof %d\n",sizeof(void*)); for(;;); return 0; }
一勤天下无难事。