Checking if RTTI is available.

Hi all. I was wondering if boost has any portable way for detecting whether RTTI is enabled? (For instance a macro expanding to _CPPRTTI in Visual Studio). If there is, I have not been able to find it. Best regards, Jurko

I was wondering if boost has any portable way for detecting whether RTTI is enabled? (For instance a macro expanding to _CPPRTTI in Visual Studio). If there is, I have not been able to find it.
No, we don't have a macro for that; BTW I think the Visual C++ is about the only compiler that doesn't enable it by default :-( John.

No, we don't have a macro for that; BTW I think the Visual C++ is about
Hi John. the
only compiler that doesn't enable it by default :-(
Would it be possible to add this to boost? Something like BOOST_HAS_RTTI? It seems like the best place to put such a macro. The question is just whether enough people would find this useful. Currently I am doing a dynamic_cast if RTTI is available in a debug build in order to assert that the cast is valid. Otherwise a static_cast is used. Regards, Jurko

On Thu, Sep 02, 2004 at 01:24:44PM +0200, Jurko Gospodnetic wrote:
Hi John.
No, we don't have a macro for that; BTW I think the Visual C++ is about the only compiler that doesn't enable it by default :-(
Would it be possible to add this to boost? Something like BOOST_HAS_RTTI? It seems like the best place to put such a macro.
Note that parts of Boost simply won't compile with "g++ -fno-rtti", lexical_cast for instance. If there were a BOOST_NO_RTTI macro then bad_lexical_cast could be changed so it doesn't use std::type_info and typeid() but that would make it pretty much useless. Also, as already pointed out, BOOST_NO_RTTI would imply different things on different compilers, so it might be necessary to have BOOST_NO_DYNAMIC_CAST, BOOST_NO_TYPEID etc. jon -- "If you think you know what the hell is going on, you're probably full of shit." - card on R.A.W.'s desk

"Jurko Gospodnetic" wrote:
Currently I am doing a dynamic_cast if RTTI is available in a debug build in order to assert that the cast is valid. Otherwise a static_cast is used.
Use something like checked_cast: http://gimite.ddo.jp/gimite/cppmess/checked_cast.txt&e=7507 /Pavel

Hi Pavel.
Use something like checked_cast: http://gimite.ddo.jp/gimite/cppmess/checked_cast.txt&e=7507
That link seems to be broken for me... :-( Will google now though... :-) Regards, Jurko

Use something like checked_cast: http://gimite.ddo.jp/gimite/cppmess/checked_cast.txt&e=7507
That link seems to be broken for me... :-( Will google now though... :-)
Google cache: http://216.239.59.104/search?q=cache:502YpLDFLyoJ:gimite.ddo.jp/gimite/cppmess/checked_cast.txt+checked_cast&hl=en&start=7 /Pavel

Jurko Gospodnetiæ wrote:
Hi all.
I was wondering if boost has any portable way for detecting whether RTTI is enabled? (For instance a macro expanding to _CPPRTTI in Visual Studio). If there is, I have not been able to find it.
No, there is no BOOST_NO_RTTI. BTW "no RTTI" on g++ means no RTTI, period. On MSVC, it means "no dynamic_cast or typeid on polymorphic types, but everything else (f.ex. typeid(T) for a type) works".
participants (6)
-
John Maddock
-
Jonathan Wakely
-
Jurko Gospodnetic
-
Jurko Gospodneti�
-
Pavel Vozenilek
-
Peter Dimov