What's causing this issue (as described in the subject header)?
Please see attached test case.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
What's causing this issue (as described in the subject header)?
Please see attached test case.
You define the type TABLE with ...
#ifdef __cplusplus extern "C" { #endif typedef struct { unsigned int index; signed long int (*pRead)(void); signed long int (*pWrite)(void); } TABLE; #ifdef __cplusplus } #endif /* extern "C" */
Note the extern "C" linkage block. Then you define two functions ...
signed long int func1(void) { return 0; } signed long int func2(void) { return 0; }
Note how there is no extern "C" linkage block here.
Then you define an instance of a TABLE ...
const TABLE table[] = { {0, func1, func2 } };
The is where the type TABLE and the function addresses are put together. Recall the diagnostic says
entity of type "signed long (*)() C"
Notice that capital C at the end? This is referring to the type of the function pointer within the type TABLE. It expects a normal C (not C++) function. You are initializing it with a C++ (not C) function. The answer is to make them agree on this detail. Either wrap all of them in extern "C", or none of them.
Thanks and regards,
-George