Results 1 to 6 of 6

Thread: Evil Class Exporting

  1. #1
    Zaei
    Guest

    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.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3
    Zaei
    Guest
    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.

  4. #4
    Zaei
    Guest
    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.

  5. #5
    Member
    Join Date
    Oct 2000
    Location
    Aiken, SC
    Posts
    36

    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.

  6. #6
    Zaei
    Guest
    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
  •  



Click Here to Expand Forum to Full Width