If I have a struct like
struct list_head {
struct list_head *next, *prev;
};
so I like to know what is the point of this struct?
what next
and priv
can contain. since its a pointer. I really don't know its size
if I have simple code like below
struct list_head
{
struct list_head *next, *prev;
} *p,v;
printf("%lu %lu %lu ...",sizeof(p),sizeof(*p),sizeof(v));
the output shows
8 16 16 .
but the thing I am confused with is how I can use the struct. What I will assigned to it
Up until now I was under the impression that we do and must need primitive types to define a type. For example this makes sense
struct a{
int *x;
char b[100];
};
struct b{
struct a *p;
}
so in above struct the child contains primitive types. In what way I get the output of my first program 8 16 16 ...
how my struct got even evaluated. is there anything I am missing? p is pointer but how 8 is printed? who defined the size of struct a
to be 8 Obviously I didn't.
Also how to use my first example struct
this one
struct list_head {
struct list_head *next, *prev;
};