First of all, thank you to whoever is reading and to whom you can respond.
This part of code, is part of an interface library gui, totally written in c.
But I'm tempted to compile these written files in c, with a c ++ compiler to be able to integrate into a program I'm doing with wxwidgets.
Within the c files, I have several function calls that have as arguments, pointers to other functions.
typedef struct {
void (*fchd_ptr)(bool);
uint16_t xpos;
uint16_t ypos;
...
...
}BUTTON_t;
void BT_SetHandler(BUTTON_t* ptr, void* fchd_ptr)
{
if (ptr == NULL)
return;
ptr->fchd_ptr = fchd_ptr; // OK in C, ERROR In C++
}
When I try to compile in C ++, I get this error.
ptr-> fkt_ptr = fkt_ptr;
// error: invalid conversion from 'void *' to 'void (*) (bool)' [-fpermissive]
If I cast an explicit cast.
ptr-> fkt_ptr = (bool *) fkt_ptr;
// error: can not convert 'bool *' to 'void (*) (bool)' in assignment
Any help, and explanation how to solve it will be welcome.