F
fkater
I have got these two structs where the second is embedding the first:
typedef struct{
int i1;
int i2;
}struct1;
typedef struct{
int i3;
struct1 s;
}struct2;
Then, the second struct is passed as a void pointer argument in the
callback function f:
void f(void* struct_of_type_struct2_expected){...};
My question is why I simpy can't access i2 like this:
((struct2*)struct_of_type_struct2_expected)->s.i2
but have to cast s into struct1 explicitly first:
(struct1)(((struct2*)struct_of_type_struct2_expected)->s).i2
Felix
typedef struct{
int i1;
int i2;
}struct1;
typedef struct{
int i3;
struct1 s;
}struct2;
Then, the second struct is passed as a void pointer argument in the
callback function f:
void f(void* struct_of_type_struct2_expected){...};
My question is why I simpy can't access i2 like this:
((struct2*)struct_of_type_struct2_expected)->s.i2
but have to cast s into struct1 explicitly first:
(struct1)(((struct2*)struct_of_type_struct2_expected)->s).i2
Felix