I need help in function pointers.
I have two function pointer types:
typedef void (*draw_func1_t)(void* data, void* painter, double x, double y);
typedef void (*draw_func2_t)(void* data, MyPainter* painter, double x, double y);
The two types are almost the same, except the second parameter. Now I need to write a function that convert a draw_func1_t to draw_func2_t:
draw_func2_t convert_func_p(draw_func1_t func) { ... }
How can I write it? Can I just force a cast like
return (draw_func2_t)func;
because the two function prototypes are binary compatible?