I recently started porting an application to Android using the NDK and I encountered the following error:
boost/function/function_base.hpp:220: error: cannot use typeid with -fno-rtti.
Ordinarily, I wouldn’t think twice about that error, but the visual studio project file set /GR-, which disables RTTI and has no problem using boost::function.
My theory on this is that because typeid is evaulated by the compilier when the static type can be determined, that must be the case for every usage of boost::function in the application. Visual Studio must be attempting to determine the static type first while GCC immediately throws the error on typeid before attempting to evaluate it.
Does that sound right? If not, what is going on?
I’m not booted into my Windows partition, but it was just as simple to look this up in MSDN.
As per this link on MSDN:
In other words, if the expression’s type can’t be inferred at compile time, and no /GR, then you’re going to get an exception or compiler error. But the second paragraph kind of implies it can infer non-ambiguous types at compile time.