calling C functions from C++ code
I've been having issues with this lately. I have written a .h file and a .c file, both with c code. I tried to include them in my project by following this tutorial:
[32] How to mix C and C++ ..Updated!.., C++ FAQ
More specifically:
Code:
#ifdef __cplusplus
extern "C" {
#endif
and
Code:
#ifdef __cplusplus
}
#endif
surrouding the code in my .h file, and then in my c++ code I #include like this:
Code:
extern "C" {
#include "myheader.h"
}
When I surround the function call in an extern "C" block, it gives me an error "linkage specification not allowed". When I take the extern "C" surrounding the function call, I am not sure what I am missing, but when I try to run my code, it finds the .h file just fine but gives me an error that the function called has a prototype but no body. Am I supposed to compile the C code separately? Any idea?