Thread: VC++6: exporting classes containing templates

  1. #1
    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,708
    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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    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, 05: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