I am updating some old C++ code.
I've come across the following:
#if defined( _CPPRTTI ) || defined( __GNUG__ )
const char* default_name{ (typeid(FooClass)).name() };
#else
const char* default_name{ "unknown" };
#endif
RTTI is Run-Time Type Information, it looks as though it is dealing with certain compilers that did't support typeid().
But this code is > 15 years old.
Can one assume that RTTI support is in place for C++11?
Some compilers allow you to disable support for RTTI at compile-time. For example, see Visual C++'s /GR- and GCC's -fno-rtti.
If you don't use RTTI in your program (
typeid
,dynamic_cast
, etc.) then disabling RTTI at compile-time may substantially reduce the size of the final binary.