Can anybody tell me how to activate RTTI in c++ when working on unix. I heard that it can be disabled and enabled. on my unix environment,how could i check whether RTTI is e
In g++ you can test the __GXX_RTTI macro to see if RTTI is on in your code. As others have pointed out -no-rtti turns of RTTI in g++. I would bet both these things work in clang as well.
#ifdef __GXX_RTTI
w = dynamic_cast(FooFactory(TYPE, arg));
if (w != NULL)
{
if (w->thing == OK)
FeastOnOrangUtansAndFruitBatsAndBreakfastCereals();
}
#endif
In newer C++ we will have access to feature testing macros __cpp_rtti
and many others that will make tese things easier.