Error: cannot use typeid with -fno-rtti

I get this “Can't use typeid with -fno-rtti” when I try to compile my project, I use the opencv framework. I googled the problem, but it seems that the errors that I found on the Internet are not related to my problem. I do not know if the problem is with the included ones, the code or the compiler.

Xcode gives me an error many times, but the first error is here:

virtual const std::type_info& type() { return typeid(T); } 
+6
source share
2 answers

It tells you an error directly in the message: if you use the no-rtti flag in the compiler, then typeid will not be available. Just turn on RTTI; this is part of C ++ after all.

+6
source

RTTI stands for runtime type information, and typeid RTTI function. Therefore disabling RTTI ( -fno-rtti ) also disables functions such as typeid .

For more on RTTI in C ++, see http://en.wikipedia.org/wiki/RTTI .

+2
source

Source: https://habr.com/ru/post/905061/


All Articles