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_expecte d){...};
My question is why I simpy can't access i2 like this:
((struct2*)stru ct_of_type_stru ct2_expected)->s.i2
but have to cast s into struct1 explicitly first:
(struct1)(((str uct2*)struct_of _type_struct2_e xpected)->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_expecte d){...};
My question is why I simpy can't access i2 like this:
((struct2*)stru ct_of_type_stru ct2_expected)->s.i2
but have to cast s into struct1 explicitly first:
(struct1)(((str uct2*)struct_of _type_struct2_e xpected)->s).i2
Felix
Comment