This question appeared when I recently opened a rather old driver for my raid device. To be able to compile the driver for a Linux system, I started to investigate on all those errors I got on output. And I came across this kind of syntax used in the driver sources:
struct file_operations t3_fops = {
owner: THIS_MODULE,
ioctl: ft_ioctl,
fasync: ft_fasync,
open: ft_open,
release: ft_release
};
So guys, could you help me to understand what does ":" mean? Is this C syntax at all? I know there is a bit field definition, but this looks rather different to me.
Structures (also called structs) are a way to group several related variables into one place. Each variable in the structure is known as a member of the structure. Unlike an array, a structure can contain many different data types (int, float, char, etc.).
An important thing to remember, at the moment you initialize even one object/ variable in the struct, all of its other variables will be initialized to default value. If you don't initialize the values in your struct, all variables will contain "garbage values".
The general syntax for a struct declaration in C is: struct tag_name { type member1; type member2; /* declare as many members as desired, but the entire structure size must be known to the compiler. */ };
Buildings, aircraft, skeletons, anthills, beaver dams, bridges and salt domes are all examples of load-bearing structures. The results of construction are divided into buildings and non-building structures, and make up the infrastructure of a human society.
This syntax for initializing structure members is called a designated initializer. The :
is older GCC-specific syntax. This is documented in the GCC manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With