$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-20 08:31:31
In that case, I expect the STLport to have the same problem, for example,
with the template member functions of std::string, since in the DLL version
std::string is explicitly instantiantiated inside the STLport DLL. Boris,
can you confirm/deny this?
Thanks,
Dave
----- Original Message -----
From: "Schaible, Joerg" <Joerg.Schaible_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, October 20, 2000 3:04 AM
Subject: RE: [boost] shared_ptr hierarchy question
Hi David,
> Sorry, I don't understand. Since all template member
> functions are inline in
> MSVC, how can they interact with anything at link time?
Just a little example hacked down here into the mail to illustrate the
problem for MSVC.
Code that will be provided in an DLL:
==== ExampleClass.hpp ======
#ifdef BUILD_EXAMPLE_DLL
#define EXAMPLE_EXPORT __declspec(dllexport)
#else
#define EXAMPLE_EXPORT __declspec(dllimport)
#endif
#include <boost/smart_ptr.hpp>
class EXAMPLE_EXPORT InternalHelper
{
};
// Have to do export the instanciated template for MSVC to link the DLL
extern template class EXAMPLE_EXPORT boost::shared_ptr<InternalHelper>;
class EXPORT Example
{
boost::shared_ptr<InternalHelper> sptrHelper;
public:
Example();
template <class X> void print( const X& x ) { std::cout << x; }
};
======== EOF ====
I omit the .cpp. Now I show you the usage of this class from an application
using the DLL.
==== Application.cpp ======
#include <ExampleClass.hpp>
int main()
{
Example e;
e.print(3);
return 0;
}
======== EOF ====
This will result in a linker error, if my code in the DLL never use this
instanciation of the member with an int. MSVC expects *every* instanciation
of the member template function coming out of that DLL and that is not
possible!
Greetings,
Jörg