VC++6: exporting classes containing templates

This is a discussion on VC++6: exporting classes containing templates within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I need some help with my current project. Our idea was to create a main shared library (DLL) that ...

  1. #1
    ttt
    ttt is offline
    Registered User
    Join Date
    Sep 2003
    Posts
    3

    VC++6: exporting classes containing templates

    Hello,
    I need some help with my current project. Our idea was to create a main shared library (DLL) that provides a couple of commonly used classes, like abstract file handling. These would then be imported by various other shared libraries, e.g. to load a file.
    Now for the classes to be used in other libraries, you have to DLLEXPORT each of them. And there's the problem:
    Code:
    class DLLEXPORT NSNamespace : public NSObjectData {
    	typedef class DLLEXPORT std::map<std::string, NSObject> MemberList;
    
    	MemberList	m_members;
    
    public:
    	// some more code follows down here
    };
    Exporting this class does not work, because upon exporting a class, you have to make sure that all other classes you're using in that class are exported, too. Now MemberList is a template, and std::map internally uses std::tree. What happens is that VC++ refuses to export NSNamespace because I haven't exported the std::tree class that was built out of the template. Well, I simply can't export that class, I do not have any access to it as it's created upon compile time.

    Is there any chance to export that class without moving the whole stuff into a static library? Perhaps there's some compiler switch which exports all symbols in a library (that would be perfectly fine)?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    This may work:

    Code:
    class DLLEXPORT NSNamespace : public NSObjectData {
    typedef std::map<std::string, NSObject> MemberList;
    MemberList	m_members;
    public:
    	// some more code follows down here
    };
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  3. #3
    ttt
    ttt is offline
    Registered User
    Join Date
    Sep 2003
    Posts
    3
    Nope, that doesn't work, as VC++ then complains that the class used for m_members is not exported.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  2. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  3. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  4. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21