I'm guessing that you have a header that contains a prototype for the SdhcInitialize()
function, and that the header was written for use by C programs. So for example, the header file might include something like the following line:
SD_API_STATUS SdhcInitialize(DWORD slot);
without being enclosed in an extern "C" {}
block (since the header is intended for C programs).
Additionally, I suspect that this header is being included - directly or indirectly - by file_1.cpp
This means that the header cannot be included in a C++ program without some additional work being done, otherwise the C++ program will see the declaration as meaning that SdhcInitialize()
has C++ linkage.
You have two reasonable approaches to fixing this:
if you can modify the header, add the following lines around the declarations in the header:
#if __cplusplus extern "C" { #endif // declarations go here #if __cplusplus } #endif
This way, C++ files will have the declarations enclosed in a
extern "C"
linkage block, while C program will not see theextern "C"
bits (which would otherwise confuse the C compiler).I think an argument can be made that all C headers should include something like those lines so that the C functions can be consumed by C++ programs without hassle.
if you cannot modify the header for some reason, you can work around the problem by including the header in C++ files like so:
extern "C" { #include "Sdhc-header.h" }