DLL in C++

Hi All,

Currently I developed an application which some modules need to be produced as a DLL (ie. void __declspec(dllexport) testing (MyClass obj); )

So, in my Solution, I create 2 project (Main project and DLL project). In DLL project, I added "_DLL" in preprocessor configuration.

As you can see in the header export function, Main program will pass object of MyClass when it want to call. here is the example definition of MyClass :

MyClass.h
---------
class MyClass {
private:
int a;
public:
void add ();
};

MyClass.cpp
-----------
void MyClass:add() {
a++;

#ifndef _DLL
printf("a has been added"); // this part will not be compiled in DLL
#endif
}

Since I pass object of MyClass into DLL, both project need to have the definition. However, the body of 'add' function is difference in Main and in DLL.

I have tested it and it run as I expected but will it cause a problem in the future ?

Thanks in advance.
Last edited on
Topic archived. No new replies allowed.