As mentioned in other answers, this is probably due to a C ++ name change. If you want a character to be accessible with this "unmangled" name and implemented in C ++, you will need extern "C" to tell the C ++ compiler that it has a C link.
In the header, which has a function prototype, you need something like:
#if defined(__cplusplus) extern "C" { #endif
This ensures that if the function is used by the C ++ compiler, it will receive extern "C" in the declaration and that if it is used by the C module, it will not be confused with the extern "C" qualifier.
Implementation in a .cpp file is not necessary if you include a header before defining a function. He will use the binding specification that he saw from the previous declaration. However, I still prefer to decorate the function definition with extern "C" just to keep everything in sync (note that in the .cpp file you don't need #ifdef - it will always compile as C ++.
source share