Am 24.03.19 um 07:52 schrieb Bonita Montero:
> Does anyone know how throwing exceptions across DLL-boundaries does
> work?
It works if and only if all library modules are compiled with the same
toolset, preferable in one build process to avoid minor differences, and
if all of them share the same runtime library instance, i.e. no static
linkage.
> If all objects would store a pointer to a virtual-method-table
> together with RTTI-information like objects which have virtual methods,
> identifying the species of a thrown object would be very easy. But in
> this case if we would have compiled two modules in two DLLs, the VMT-
> and RTTI-information would be distinct for two logically identic
> objects because there VMT- and RTTI-information would exist multiple
> times in memory.
That's no big deal if they are identical.
> But classes for exceptions don't necessarily have to have virtual
> methods and thereby no VMT- and RTTI-informations. So I assume that
> when I throw an exception, the object thrown I throw would get handed
> along with an additional pointer to a kind of RTTI-information. But in
> this case we would have the same problem that with separately compiled
> DLLs this information might be distinct.
If you violate the ODR everything could happen.
> So is there any way to mark a
> class external in a way that this RTTI-like information is stored only
> once in either DLL?
I have no idea how this is implemented, but it works. I already used
this in late 90's.
The only question that arises. When all DLL modules need to be from one
build process, why are there separate modules at all? So throwing across
DLL boundaries is of little use in most cases.
Marcel