let's assume that we have below struct definitions:
typedef struct {
uint8_t a ;
} deepest_t ;
typedef struct {
deepest_t* deepest_ptr ;
} deeper_t ;
typedef struct {
deeper_t* deeper_ptr ;
} deep_t ;
typedef struct {
void* data ;
} data_container_t ;
and following initializations:
deepest_t deepest = {
.a = 5,
} ;
deeper_t deeper = {
.deepest_ptr = &deepest,
} ;
deep_t deep = {
.deeper_ptr = &deeper,
} ;
and now question, could you please tell me how to initialize void* data
by usage of the designated initializer in order to void* data
will point the deepest_t deepest
. I've tried such a solution, but compiler is screaming that it is not a const value :
data_container_t data_container = {
.data = &(((deeper_t*) deep.deeper_ptr)->deepest_ptr),
} ;