There are a few questions on throwing from constructors and throwing across DLL boundaries but I can't find one that answers this specific situation.
Two things I've read:
Constructors should throw exceptions if something bad happens. This ensures that objects are not left in a zombie state, removes the need for functions to check the state of an object, and enforces RAII. All good things.
We shouldn't throw across DLL boundaries. Heap memory is not shared, and bad things can happen. The details of this escape me a bit, but general advice everywhere is not to do it, and so I wont. The exception (!) here, is when all code is compiled with the same compiler, but even that seems to be compiler specific and so not reliable. Error codes it is!
Now my question:
How do I safely create an instance of a class which is defined somewhere in a DLL?
I think that maybe the only safe way to do this is to make all (Exported) constructors in the DLL promise not to throw exceptions, or perhaps to provide exported free functions which return a pointer to an object which could be NULL if an exception was caught.
Can anyone suggest anything more suitable, or tell me I've got the wrong end of the stick?