Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Templates & DLL

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hi everybody !

Here is my problem:

All the classes of my game engine are located in a DLL. Here is how I declare a class:
> class ENGINE_API RLClassName
> {
> blabla
> };

Where ENGINE_API is:
> #ifdef ENGINE_EXPORTS
> #define ENGINE_API __declspec(dllexport)
> #else
> #define ENGINE_API __declspec(dllimport)
> #endif
It's some MS Visual Studio code for my DLL.
Now, if I want to declare this class:
> class RLTest
> {
> long lTest;
> };
Then, if I declare a RLTest variable in this class:
> class ENGINE_API RLClass
> {
> RLTest myVar;
> };

I get a C4251 warning, here is the MSDN doc about this warning:
>Compiler Warning (level 1) C4251
>'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'

>The specified base class was not declared with the __declspec(dllexport) keyword.

>A base class or structure must be declared with the __declspec(dllexport) keyword if a function in a derived class is to be exported.

For me, it's not a problem, I changed the declaration code of the RLTest class from
"class RLTest" to "class ENGINE_API RLTest"

Until here, everything is OK but....
I recently tried to make templates for my maths classes (and theses maths classes must use floats when running the game AND use doubles when running some tools). The problem is that the C4251 warning is back and I couldn't manage to make it run away.
Here is how I declared my template:
>template <class TYPE>
>class ENGINE_API RLVertex3D
> {
> blabla
> };

Then I wrote a define:
>#define RLVERTEX32 RLVertex3D<float>

And everything went wrong. For every RLVERTEX32 variable declared in my ENGINE_API classes, I get a C4251 warning. I tried to put the ENGINE_API at different places of the code, but it didn't work. I looked in the MSDN docs but I didn't find the answer.

I must precise that, except that annoying warning message, everything works:
my maths classes work in my DLL and outside my DLL (from my MAP file converter, which is linked to the DLL). What should I do ? Is it safe only yo disable this warning or must I do something else ?

Thanks forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top