Ausnahmen über die binäre Grenze

Ich weiß, diese Frage wurde schon einige Male gestellt, aber ich kann keine Lösung für mein Problem finden.

Ich habe folgende Situation:

   A
  / \
 /   \
B <-- C
A ist eine gemeinsam genutzte Bibliothek, die die Klasse enthältEExceptionB und C Link gegen AC ist auch eine gemeinsam genutzte BibliothekB lädt C dynamisch zur Laufzeit

Irgendwann wirft C eine Instanz vonEException:

void doSometing() {
    throw EException("test-message");
}

imB Ich möchte diese Ausnahme abfangen:

try {
    doSomething();
} catch (const EException& ex) {
    // Not reached
} catch (...) {
    // Not reached
}

aber wie im Code erwähnt, wird keine der catch-Klauseln aufgerufen. Stattdessen wird der Thread, in dem dieser Code ausgeführt wird, abgebrochen.

Ich habe folgende Dinge ausprobiert:

Das Sichtbarkeitsattribut vonEException wird beim Kompilieren von A auf "default" gesetztDasEException Header-Datei enthält nur DeklarationenIch benutze die Linker-Option-fvisibility=hidden in A, B und CIch benutze die Linker-Option-E in c

Verwendennm Ich bekomme dafürA:

0000000000066260 T EException::EException(QString const&)
0000000000066306 T EException::EException(EException const&)
00000000000661d0 T EException::EException() 
0000000000066260 T EException::EException(QString const&) 
0000000000066306 T EException::EException(EException const&) 
00000000000661d0 T EException::EException() 
00000000000664de T EException::~EException()
000000000006641e T EException::~EException() 
000000000006641e T EException::~EException() 
00000000000663b6 T EException::operator=(EException const&)
<...>
000000000028de40 V typeinfo for EException
000000000028dd80 V typeinfo for EException*
000000000007342b V typeinfo name for EException
0000000000072ab7 V typeinfo name for EException*
000000000028de00 V vtable for EException

zumB:

U EException::EException(QString const&)
U EException::~EException()
<...>
0000000000726f60 V typeinfo for EException

und fürC:

U EException::EException(QString const&)
U EException::~EException()
<...>
U typeinfo for EException

Könnte das Problem sein, dassB verwendet eine eigene typeinfo vonEExceptionwährendC verwendet die vonA? Wie würde ich das beheben?

Meine Umgebung:

gcc 4.6.3 unter x86_64-linux-gnumit Qt

Danke für deine Hilfe!

Antworten auf die Frage(5)

Ihre Antwort auf die Frage