I am trying to create a C++ DLL that I can import in c#, but my code won't compile.
Here is the code:
//main.cpp #include "C:\Users\Mihai\Desktop\body.cpp" #include "C:\Users\Mihai\Desktop\header.h" extern "C"_declspec(dllexport) int sumTwo(int var_x, int var_y) { myClass MC(var_x, var_y); return MC.sumX_Y(); } //body.cpp #pragma once #include "Header.h" myClass::myClass(int var_x, int var_y) { x = var_x; y = var_y; } int myClass::sumX_Y() { return x + y; } //Header.h #pragma once class myClass { public: myClass(int var_x, int var_y); int sumX_Y(); private: int x; int y; }; /*
Here are the errors:
Severity Code Description Project File Line Suppression State Error (active) E0130 expected a '{' SumadllptCsharp e:\work\Info\SumadllptCsharp\SumadllptCsharp\main.cpp 4 Error (active) E0040 expected an identifier SumadllptCsharp e:\work\Info\SumadllptCsharp\SumadllptCsharp\main.cpp 4 Error (active) E0020 identifier "dllexport" is undefined SumadllptCsharp e:\work\Info\SumadllptCsharp\SumadllptCsharp\main.cpp 4 Error (active) E0020 identifier "var_x" is undefined SumadllptCsharp e:\work\Info\SumadllptCsharp\SumadllptCsharp\main.cpp 6 Error (active) E0020 identifier "var_y" is undefined SumadllptCsharp e:\work\Info\SumadllptCsharp\SumadllptCsharp\main.cpp 6 Error C3690 expected a string literal, but found a user-defined string literal instead SumadllptCsharp e:\work\info\sumadllptcsharp\sumadllptcsharp\main.cpp 4 Error C2144 syntax error: 'int' should be preceded by ';' SumadllptCsharp e:\work\info\sumadllptcsharp\sumadllptcsharp\main.cpp 4 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int SumadllptCsharp e:\work\info\sumadllptcsharp\sumadllptcsharp\main.cpp 4