xcode 错误:无法将 typeid 与 -fno-rtti 一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8723702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: Cannot use typeid with -fno-rtti
提问by Gustavo
I′m getting this "Cannot use typeid with -fno-rtti" when I′m trying to compile my project, I′m using an opencv framework. I googled the problem but, it seems the errors I found in internet does not have relation with my problem. I don′t know if the problem is related with the includes, the code or the compiler.
当我尝试编译我的项目时,我收到了“不能将 typeid 与 -fno-rtti 一起使用”的消息,我使用的是 opencv 框架。我用谷歌搜索了这个问题,但似乎我在互联网上发现的错误与我的问题无关。我不知道问题是否与包含、代码或编译器有关。
Xcode is giving me the error a lot of times, but the first error is here:
Xcode 给我很多次错误,但第一个错误在这里:
virtual const std::type_info& type() { return typeid(T); }
采纳答案by GManNickG
It's telling you the error right in the message: if you use the no-rtti
flag on the compiler, then typeid
is not going to be available. Just enable RTTI; it's part of C++ after all.
它在消息中告诉您错误:如果您no-rtti
在编译器上使用该标志,则将typeid
不可用。只需启用 RTTI;毕竟它是 C++ 的一部分。
回答by Some programmer dude
RTTI stands for Run Time Type Information, and typeid
is an RTTI-feature. So turning off RTTI (-fno-rtti
) also disables features like typeid
.
RTTI 代表运行时类型信息,typeid
是一种 RTTI 功能。因此,关闭 RTTI( -fno-rtti
) 也会禁用typeid
.
See http://en.wikipedia.org/wiki/RTTIfor more information about RTTI in C++.
有关C++ 中 RTTI 的更多信息,请参阅http://en.wikipedia.org/wiki/RTTI。