I know there are many SO questions related to this, but none of the ones I've come across solve my problem. So here goes.
I have a C++
file and method:
MyClass.cpp
extern "C" {
#include "C_methods.h"
}
void MyClass::run_c_method_1()
{
std::string filename_1 = <from somewhere else>;
std::string filename_2 = <from somewhere else>;
c_method_1(filename_1.c_str(), filename_2.c_str());
}
C_methods.h
#ifndef Project_C_methods_h
#define Project_C_methods_h
int c_method_1(char* filename1, char* filename_2);
#endif
C_methods.c
#include "C_methods.h"
int c_method_1(char* filename1, char* filename_2) {
/* Do some stuff */
return 0;
}
I'm building/running this on OSX
in Xcode
, and the compiler is telling me:
No matching function call to 'c_method_1'
.
To me, this makes no sense. From other SO answers, it looks like the extern
I've wrapped the header #include "C_methods.h"
in should tell the compiler that those functions are present, and to be compiled in C
.
Does anyone have any idea where I could be going wrong here? I'm stumped.