07-25-2014, 06:41 AM
Macro Macro2345
With COM interface more work. If don't need to export non-static class members, better use extern "C".
//Put this before a non-class function declaration and definition to export the function with __cdecl calling convention. It is the easiest way, don't need a .def file. Using Microsoft Visual C++.
#define EXPORTC extern "C" __declspec(dllexport)
namespace Math
{
,class MathFuncs
,{
,,public:
,,// Returns a + b
,,static double Add(double a, double b);
,};
,double MathFuncs::Add(double a, double b) { return a+b; }
EXPORTC
double Math_Add(double a, double b) { return MathFuncs::Add(a, b); }
}
With COM interface more work. If don't need to export non-static class members, better use extern "C".