I'm having issues trying to call a function where I pass in pointers to two structs.
Please could someone explain why I can't do this...
// in types.h
typedef struct {
    uint16_t size;
    uint16_t width;
    uint16_t height;
    void (*fn_init)(void);
} display_t, *display_ptr;
typedef struct {
    uint16_t size;
    const display_ptr display;
} context_t, *context_ptr;
// in main.c
void init_context(context_ptr context, const display_ptr display) {
    context->size = sizeof(context_t);
    context->display = display;
}
const display_t g_display= {
    0,
    400,
    800,
    NULL
};
context_t g_context;
void main(void) {
    // other code here...
    init_context(&g_context, &g_display);
} 
When I call the init_context function, I get the following error:
"argument of type "display_t const *" is incompatible with parameter of type struct <unnamed> *"
However, if I alter the declaration of the init_context to be as follows:
void init_context(context_ptr context, const display_t *display);
It works!
What am I missing or not understanding?
Thanks in advance! Kev
 
    