I have a struct defined in C, it takes a pointer to a function. The functions/methods i have defined in C++. How can I pass a reference to the C++ method to the C struct?
This is the error I get: "a value of type "void (Ili9341::)(void , int16_t, int16_t, uint16_t)" cannot be used to initialize an entity of type "void ()(void , int16_t, int16_t, uint16_t) C"
This is the C file
typedef struct Graphics_Display
{
int32_t size; //!< The size of this structure.
void *displayData; //!< A pointer to display driver-specific data.
uint16_t width; //!< The width of this display.
uint16_t heigth; //!< The height of this display.
void (*callPixelDraw)(void *displayData, int16_t x, int16_t y,
uint16_t value); //!< A pointer to the function to draw a pixel on this display.
void (*callPixelDrawMultiple)(void *displayData, int16_t x, int16_t y,
int16_t x0, int16_t count, int16_t bPP, const uint8_t *data,
const uint32_t *pucPalette); //!< A pointer to the function to draw multiple pixels on this display.
void (*callLineDrawH)(void *displayData, int16_t x1, int16_t x2, int16_t y,
uint16_t value); //!< A pointer to the function to draw a horizontal line on this display.
void (*callLineDrawV)(void *displayData, int16_t x, int16_t y1,
int16_t y2, uint16_t value); //!< A pointer to the function to draw a vertical line on this display.
void (*callRectFill)(void *displayData, const Graphics_Rectangle *rect,
uint16_t value); //!< A pointer to the function to draw a filled rectangle on this display.
uint32_t (*callColorTranslate)(void *displayData, uint32_t value); //!< A pointer to the function to translate 24-bit RGB colors to display-specific colors.
void (*callFlush)(void *displayData); //!< A pointer to the function to flush any cached drawing operations on this display.
void (*callClearDisplay)(void *displayData, uint16_t value); //!< A pointer to the function to clears Display. Contents of display buffer unmodified
} Graphics_Display;
This is the C++ file
Ili9341::Ili9341(void){
}
Graphics_Display Ili9341::ili9341_GetDisplay(){
Graphics_Display g_sDriver =
{
sizeof(tDisplay),
ili9341_Memory,
#if defined(PORTRAIT) || defined(PORTRAIT_FLIP)
LCD_Y_SIZE,
LCD_X_SIZE,
#else
LCD_X_SIZE,
LCD_Y_SIZE,
#endif
ili9341_PixelDraw,
ili9341_PixelDrawMultiple,
ili9341_LineDrawH,
ili9341_LineDrawV,
ili9341_RectFill,
ili9341_ColorTranslate,
ili9341_Flush,
ili9341_ClearScreen
};
return g_sDriver;
}
void Ili9341::ili9341_PixelDraw(void *displayData, int16_t x, int16_t y, uint16_t value){
}
void Ili9341::ili9341_PixelDrawMultiple(void *displayData, int16_t x, int16_t y, int16_t x0, int16_t count, int16_t bPP, const uint8_t *data, const uint32_t *pucPalette){
}
void Ili9341::ili9341_LineDrawH(void *displayData, int16_t x1, int16_t x2, int16_t y, uint16_t value){
}
void Ili9341::ili9341_LineDrawV(void *displayData, int16_t x, int16_t y1, int16_t y2, uint16_t value){
}
void Ili9341::ili9341_RectFill(void *displayData, const Graphics_Rectangle *rect, uint16_t value){
}
uint32_t Ili9341::ili9341_ColorTranslate(void *displayData, uint32_t value){
return 0;
}
void Ili9341::ili9341_Flush(void *displayData){
}
void Ili9341::ili9341_ClearScreen(void *displayData, uint16_t value){
}