Skip to content
Advertisement

struct is it declaration or defination or some type of Object Oriented behavior in kernel source

In r8169_main.c in linux kernel source there is a struct like this

JavaScript

I like to in first member .name but there is no data type specified and there is . before name like .name = KBUILD_MODNAME, what is it called. is this name member defined somewhere else what this static struct means I did not seen this type of struct before. Can any one please tell what is this and its even assigned a value in struct declaration???

can I also create array of this type of struct?

Advertisement

Answer

what is it called.

name is a member of structure struct pci_driver.

The initialization form is called designated initialization. The part .name = something is designator.

is this name member defined somewhere else

Yes, in include/linux/pci.h.

what this static struct means I did not seen this type of struct before

The line defines a variable rtl8169_pci_driver of type struct pci_driver. The static keyword modifies variable lifetime – it means the variable is valid for the whole duration of the program.

JavaScript

Research https://en.cppreference.com/w/c/language/declarations https://en.cppreference.com/w/c/language/struct_initialization https://en.cppreference.com/w/c/language/storage_duration

can I also create array of this type of struct?

You can create arrays of struct pci_drivers.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement