Click to See Complete Forum and Search --> : Exporting STL containers from DLL


donald
12-05-2000, 06:38 AM
It seems that a particular STL container needs to be exported separately from
a DLL if a client uses it, e.g as a return value from a DLL function.
Even though the surrounding class is already exported.
In other words the compiler warning 4251 needs to be removed.
Any idea how?

Ta much!

wellheadsourcepricessummaryextractor.h(55) : warning C4251: 'mResultsCache'
: class 'std::vector<class std::map<int,struct ReportExtractor::Value,struct
std::less<int>,class std::allocator<struct ReportExtractor::Value> >,c
lass std::allocator<class std::map<int,struct ReportExtractor::Value,struct
std::less<int>,class std::allocator<struct ReportExtractor::Value> > > >'
needs to have dll-interface to be used by clients of class 'WellheadSourcePricesSummaryExtractor'

Brian Leung
12-05-2000, 07:38 AM
try

#pragma warning(disable:4251)

Brian

"donald" <dmacleod@epsedin.co.uk> wrote:
>
>It seems that a particular STL container needs to be exported separately
from
>a DLL if a client uses it, e.g as a return value from a DLL function.
>Even though the surrounding class is already exported.
>In other words the compiler warning 4251 needs to be removed.
>Any idea how?
>
>Ta much!
>
>wellheadsourcepricessummaryextractor.h(55) : warning C4251: 'mResultsCache'
>: class 'std::vector<class std::map<int,struct ReportExtractor::Value,struct
>std::less<int>,class std::allocator<struct ReportExtractor::Value> >,c
>lass std::allocator<class std::map<int,struct ReportExtractor::Value,struct
>std::less<int>,class std::allocator<struct ReportExtractor::Value> > > >'
>needs to have dll-interface to be used by clients of class 'WellheadSourcePricesSummaryExtractor'
>

Vesel
12-05-2000, 10:50 AM
I had the same problem. What I did for the solution, called the pointer of
a worker class in the DLL Export Class. Inside that worker class used the
STL.
#define IMPORT_EXPORT __declspec(dllexport)
#else
#define IMPORT_EXPORT __declspec(dllimport)
class IMPORT_EXPORT MyClass
{

private:
CWorker* pWorker;
};
and used the STL inside the worker.

"donald" <dmacleod@epsedin.co.uk> wrote:
>
>It seems that a particular STL container needs to be exported separately
from
>a DLL if a client uses it, e.g as a return value from a DLL function.
>Even though the surrounding class is already exported.
>In other words the compiler warning 4251 needs to be removed.
>Any idea how?
>
>Ta much!
>
>wellheadsourcepricessummaryextractor.h(55) : warning C4251: 'mResultsCache'
>: class 'std::vector<class std::map<int,struct ReportExtractor::Value,struct
>std::less<int>,class std::allocator<struct ReportExtractor::Value> >,c
>lass std::allocator<class std::map<int,struct ReportExtractor::Value,struct
>std::less<int>,class std::allocator<struct ReportExtractor::Value> > > >'
>needs to have dll-interface to be used by clients of class 'WellheadSourcePricesSummaryExtractor'
>