activate RTTI in c++

后端 未结 7 1771
日久生厌
日久生厌 2020-12-09 14:37

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

相关标签:
7条回答
  • 2020-12-09 15:41

    gcc has it on by default. Check if typeid(foo).name() gives you something useful.

    #include <iostream>
    #include <typeinfo>
    
    int main()
    {
     std::cout << typeid(int).name() << std::endl;
     return 0;
    }
    

    Without RTTI you get something like:

    foo.cpp:6: error: cannot use typeid with -fno-rtti
    
    0 讨论(0)
提交回复
热议问题