I need to create a C ++ project that exports functions to a project c this is my C ++ class:
** MyCppClass.h **
class MyCppClass
{
public:
static void MyCppMethod()
}
** MyCppClass.cpp **
void MyCppClass::MyCppMethod(){}
* Now I need to create an interface for the MyCppMethod (static) method.
I did this: ** MyExport.h **
#define Export __declspec(dllexport)
extern "C" void Export MyCppMethodWrapper();
** MtExport.cpp **
#include "MyCppClass.h"
#include "MyExport.h"
void MyCppMethodWrapper() { MyCppClass::MyCppMethod();}
here it is!
now part C (another project) I linked the project with MyExport.lib
** program.c **
#include "MyExport.h" ->does not compile because of the extern "C"
int main()
{
MyCppMethodWrapper();
}
if I don’t add a line: #include "MyExport.h"in program.c the program compiles and works fine, but I need to provide a header for export (the client needs a header), and I want the program to use this header. how can i solve this ???
thank you for your responses
source
share