今天在看broadcom交换芯片SDK的时候,偶然发现,结构体的赋值竟然是用了冒号!
一番搜索之后,原来是这个样子。
原文地址:http://blog.csdn.net/unbutun/article/details/4648307结构体:
struct usb_driver {
const char *name;
int (*probe) (struct usb_interface *intf,
const struct usb_device_id *id);
void (*disconnect) (struct usb_interface *intf);
int (*ioctl) (struct usb_interface *intf, unsigned int code,
void *buf);
int (*suspend) (struct usb_interface *intf, pm_message_t message);
int (*resume) (struct usb_interface *intf);
int (*reset_resume)(struct usb_interface *intf);
int (*pre_reset)(struct usb_interface *intf);
int (*post_reset)(struct usb_interface *intf);
const struct usb_device_id *id_table;
struct usb_dynids dynids;
struct usbdrv_wrap drvwrap;
unsigned int no_dynamic_id:1;
unsigned int supports_autosuspend:1;
unsigned int soft_unbind:1;
};
变量赋值:
struct usb_driver rtusb_driver = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
.owner = THIS_MODULE,
#endif
.name="rt2870",
.probe=rtusb_probe,
.disconnect=rtusb_disconnect,
.id_table=rtusb_usb_id,
#ifdef CONFIG_PM
suspend: rt2870_suspend,
resume: rt2870_resume,
#endif
};
给结构体中的非指向函数指针赋值用. (.name="rt2870",) 给指向函数指针赋值用冒号(resume: rt2870_resume,)