Cannot use typeid with -fno-rtti错误的解决

来源:互联网 发布:阿里云 包括域名 编辑:程序博客网 时间:2024/06/06 05:01
今天编译我的项目时遇到了 error:flann/any.h:Cannot use typeid with -fno-rtti 这个错误。
google了一下发现是编译器关掉了RTTI (Run-Time Type Information, orRun-Time Type Identification)支持。
 
然后在makefile 的 CXXFLAGS 里去掉 -fno-rtti即可。
关于RTTL:

The dynamic_cast<> operation andtypeid operator in C++ are part of RTTI.

The C++ run-time type information permits performing safetypecasts and manipulate type information at run time.

RTTI is available only for classes which arepolymorphic, which means they have at least one virtual method. In practice, this is not a limitation because base classes must have a virtual destructor to allow objects of derived classes to perform proper cleanup if they are deleted from a base pointer.

RTTI is optional with some compilers; the programmer can choose at compile time whether to include the function. There may be a resource cost to making RTTI available even if the program does not use it.

原创粉丝点击