While I am studying device driver I bump into this code below.
static struct char_device_struct{
struct char_device_struct *next;
...
} *chrdevs[CHRDEV_MAJOR_HASH_SIZE];
I thought it could be defining struct array, so I wrote a simple code like this below and found strange things.
struct a{
int _a;
} val_a[10];
struct b{
int _b;
};
struct b val_b;
int main(){
val_a->_a=10;
val_b._b=10;
return 0;
}
val_a is accessible by "->" like allocated memory in heap or mmap(accessing by pointer) but not accessed like ".".
- what does it mean to use struct like array(e.g. CHRDEV_MAJOR_HASH_SIZE)
- and if it is just defining struct array what is difference between just using like val_b.
Sorry for the bad English. Thank you very much.