[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: shared library RTTI with gcc
- From: "Wim Couwenberg" <wim.couwenberg@...>
- Date: Sat, 6 Oct 2007 09:19:44 +0200
> Now serious, can someone enlighten me about why RTTI needs this global
> flag?
c++ defines some implicit structures for types to support RTTI such as
type_info instances and implicit entries in an object's virtual
function table. These structures are implicitly defined in *all*
libraries that refer the type. If different libraries link to their
*own* instance of such structures then RTTI fails, for example a
dyamic_cast will always fail between objects created in different
libraries. Not specifying RTLD_GLOBAL will keep these implicit
structures local to the loaded library and the linker selects the
local instance instead of the first global instance that it
encountered.
A public c++ module interface should ideally not rely on RTTI.
However, it is not always feasible to rewrite interfaces since there's
often a *large* existing code base that entirely depends on RTTI...
On Windows the story is completely different since dll's are already
linked. The type info structures are explicitly placed in a shared
administration to make RTTI work.
--
Wim