swiftcoder wrote:
OK, so the problem with dynamic plugins is MSVC, in particular exporting classes which contain a std::container from a DLL. Microsoft seems to say this is not possible, so we had perhaps better avoid the problem altogether (I wonder about this though - OGRE's public interface is littered with STL classes, and it works fine with MSVC).
As far as I can tell, the only STL class that is widely used publicly in Horde's C++ interface is std::string, which can be exported from DLLs.
Do you have a link about this MSVC / STL exporting problem? I primarily use MSVC for work, so I can test some implementations if need be.
As far as I know, MSVC will happily export anything from a DLL, including STL classes. The problem with doing so is a Windows/DLL limitation. On Windows, each DLL is assigned it's own heap.
Here's an example: "DLL A" initialises a std::string to "a", and then "DLL B" assigns that same string to "foo". This means that DLL A allocates some memory in DLL A's heap. Then DLL B tries to free that allocation from DLL B's heap, which causes heap corruption in DLL B and a memory leak in DLL A.
All of this occurs simply because DLL A and DLL B both link to the STL statically - if the STL was in it's own dynamic library, then all STL allocations would occur on the heap of that DLL (but I don't think that's possible to do...).
So in short, you *can* export anything on Windows, you've just got to be careful not to take ownership of any dynamically allocated memory that is exported.
For example, it would be absolutely fine to export a read-only std::vector, because then memory-ownership won't be transferred:
__declspec(dllexport) const std::vector<int>& GetVector();