|
-
Feb 27th, 2002, 06:31 PM
#1
Evil Class Exporting
Well, this is getting annoying. I have something along these lines:
Code:
class __declspec(dllexport) IMesh : public IObject, IThinker, IRenderable
{
...
protected:
CSmartPtr<IVertexBuffer> myVB;
...
};
On every compile, I get a warning that says something like this:
Code:
'myVB': 'CSmartPtr<IVertexBuffer>' must have dll-interface to be used by clients of 'IMesh'
MSDN says that the base class has to be defined with __declspec(dllexport). So, i spent a while adding __declspec(dllexport) to every class that has anything to do with anything. I get the same thing. Am I missing something, or doing something totally wrong?
Z.
-
Feb 28th, 2002, 02:47 PM
#2
Monday Morning Lunatic
You need to explicitly instantiate the template:
Code:
template class CSmartPtr<IVertexBuffer>;
...or something, can't quite remember.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 28th, 2002, 04:21 PM
#3
Yep. I figured that out this afternoon. Now I get errors that say that I am redefining the class "CSmartPtr<IVertexBuffer>". Where should I put the explicit instantiation?
BTW, its class a<b> {};, or template<> class a<b> {};.
Z.
-
Feb 28th, 2002, 09:18 PM
#4
Well, I got it going...
In the DLL:
Code:
template class __declspec(dllexport) CSmartPtr<IVertexBuffer>;
and in the Exe:
Code:
extern template class __declspec(dllimport) CSmartPtr<IVertexBuffer>;
This is apparently a really obscure problem. You can also use it to export classes that use an STL vector from a DLL as well:
Code:
template class __declspec(dllexport) std::vector<int>;
From what I read, this is the only class that you can export, as many of others contain nested classes, that cannot be instantiated like that, and so, cant be exported.
Z.
-
Feb 28th, 2002, 11:23 PM
#5
Member
Noooooo Not C code!! Ahhhh!!!!!
C must have been invented to lower the population of the earth.
Although I feal I have reached a point where I MUST change from VB to C++ I don't want to. I was all jazzed about it, so I could take advantage of all of C++'s capabilities like subclassign, and virtual functions, and all those other things, the developers of VB had mercy and decided not to include, and then I saw your code snippet. I have used C++ before. And I know that with enough practice, reading that code will be like reading a book (just like VB code) but it might as well be Chineese right now.
Oh well, don't mind my rambling,
Joey
You have no idea how many idiots there are among us.
Winsock is awesome!
If you are reading this, your a geek, just face it.
-
Mar 1st, 2002, 09:20 AM
#6
Dont worry about it. Its some of the more advanced stuff (if parksie AND kedaman couldnt help... =) that you wont get to for quite a while.
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|