Hi,

I am getting warnings when I export a class that contains an STL deque. Note that for a simple stl vector there are no warnings, only for the deque ... I applied the rules defined on the msn page : [url]http://support.microsoft.com/kb/168958[/url]

But still get a compile warning that I would like to get rid of.

Any hints would be appreciated !

Thanks alot !

matt-

code snippet and associated warning below :

#ifdef IPGENPROC_EXPORTS
#define IPGENPROC_API __declspec(dllexport)
#define IPGENPROC_TEMPLATE
#else
#define IPGENPROC_API __declspec(dllimport)
#define IPGENPROC_TEMPLATE extern
#endif


class IPGENPROC_API Point3D
{
public:
    short x,y,z;
public:
    bool operator < (const Point3D c) const
    {
        return (z < c. z) && (y < c. y) && (x < c.z);
    }
    bool operator == (const Point3D c) const
    {
        return (z == c. z) && (y == c. y) && (x == c.z);
    }
};

IPGENPROC_TEMPLATE template class IPGENPROC_API allocator<Point3D>;
IPGENPROC_TEMPLATE template class IPGENPROC_API deque<Point3D>;




C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\deque(54) : warning C4251: 'std::_Deque_map<_Ty,_Alloc>::_Almap' : class 'std::allocator<_Ty>' needs to have dll-interface to be used by clients of class 'std::_Deque_map<_Ty,_Alloc>'
        with
        [
            _Ty=Point3D,
            _Alloc=std::allocator<Point3D>
        ]
        and
        [
            _Ty=std::_Deque_map<Point3D,std::allocator<Point3D>>::_Tptr 
        ]
        and
        [
            _Ty=Point3D,
            _Alloc=std::allocator<Point3D>
        ]

Recommended Answers

All 2 Replies

I had that same question some time ago and was told that templates can't be exported in a DLL. So I just use a pragma to disable that warning because the class will work anyway. #pragma warning(disable: 4251)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.