Hi!
I'm currently migrating a project to VC8. The same project compiles and runs
using VC7.1 and eVC4. Now, doing so I found something strange:
I have a library (a DLL) and that lib exports a type. This type is derived
publicly from std::pair<>. Now, what I found during the research was that
this DLL also exports functions for std::pair, in this case constructor,
destructor and assignment operator, but only when compiled with VC7.1 and
later, not with eVC4. Why? All parts of std::pair are inline template code,
any code that uses my library will have these definitions in scope when it
can also use my exported type, so there shouldn't be need for that.
The problems arise with another library (this time a static library, which
was built for convenience to share code between two projects) which also
includes these very symbols that are exported from the DLL. This leads to
linker errors. The two interesting parts are
1. The exact same setup compiles and runs under VC7.1. This means either the
static lib doesn't export these symbols or they are marked as 'weak
symbols' so that duplicate definitions are silently ignored.
2. As a workaround, I included the header of the DLL in the files that cause
symbol clashes. This is really strange, it seems as if the additional
header somehow changed the declaration of std::pair (i.e. suddenly it is
imported from said DLL instead of creating inline instances) - I don't
think that's a good idea.
I'm currently trying to figure out a way to remove the std::pair from the
interface of the DLL without breaking the interface (which would be my next
option, and not necessarily the worst since the interface has assembled
some dust already and a new version is called for).
However, I'm mostly trying to understand what is going on and why, so any
pointers are welcome.
cheers
Uli