Home > use typeid > error cannot use typeid with

Error Cannot Use Typeid With

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and

Cannot Use Typeid With -fno-rtti

policies of this site About Us Learn more about Stack Overflow the how to use typeid in c++ company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags gcc_enable_cpp_rtti Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only

Gcc Fno-rtti

takes a minute: Sign up Error: Cannot use typeid with -fno-rtti up vote 6 down vote favorite 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

Enable Rtti

the problem is related with the includes, the code or the compiler. Xcode is giving me the error a lot of times, but the first error is here: virtual const std::type_info& type() { return typeid(T); } c++ objective-c xcode gcc compilation share|improve this question asked Jan 4 '12 at 8:00 Gustavo 393422 for Android NDK: cppFlags += "-frtti" –Anton Savenok Aug 25 '15 at 3:50 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted 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. share|improve this answer answered Jan 4 '12 at 8:04 GManNickG 231k29346470 1 I solved this checking "GCC_ENABLE_CPP_RTTI = YES", thank you!!! –Gustavo Jan 4 '12 at 8:18 add a comment| up vote 2 down vote RTTI stands for Run Time Type Information, and typeid is an RTTI-feature. So turning off RTTI (-fno-rtti) also disables features like typeid. See http://en.wikipedia.org/wiki/RTTI for more inform

von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen

> Programming Questions > Error: cannot use typeid with -fno-rtti Print Go Down Pages: [1] Topic: Error: cannot use typeid with -fno-rtti(Read 1 time) previous topic - next topic guix Edison Member Posts: 2,145 Karma: 308[add] Scientia potentia est. http://forum.arduino.cc/index.php?topic=134264.0 Error: cannot use typeid with -fno-rtti Nov 26, 2012, 11:52 am Hello, I try https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40160 to use the typeid function but I get this error: cannot use typeid with -fno-rttiIs there a solution ? pYro_65 Faraday Member Posts: 3,349 Karma: 614[add] Genx Re: Error: cannot use typeid with -fno-rtti #1 Nov 26, 2012, 01:48 pm There is a GCC specific 'typeof', not the same thoughhere is a use.Code: [Select]
//type based on value.
typeof( use typeid 123 ) a_byte;
typeof( 12345 ) an_int;

typedef typeof( 123456 ) MyType;
If you wish to compare types, here is one of my utility functions:Code: [Select]template< typename _A, typename _B > bool CompareType( _A a, _B b )
{
return false;
}

template< typename _A > bool CompareType( _A a, _A b )
{
return true;
}
Code: [Select]CompareType( 1, 2.0f ); //false
CompareType( 'c', 'g' ); //true
You can use it in combination with typeof for #defines or functions that don't know the incoming type. https://forum.arduino.cc/index.php?action=dlattach;topic=327736.0;attach=128670 New EEPROM library released guix Edison Member Posts: 2,145 Karma: 308[add] Scientia potentia est. Re: Error: cannot use typeid with -fno-rtti #2 Nov 26, 2012, 06:18 pm Last Edit: Nov 26, 2012, 06:20 pm by guixReason: 1 I see, thanks for this, but that's not really what I need, in fact I want a way to make a function that can handle different types of parameter, like for example:Code: [Select]
void func( int value )
{
switch typeof( value )
{
case long:
...
I believe it's not possible...I tried:Code: [Select]
void func( int value )
{
switch sizeof( value )
{
case 4:
...
But the size is always, obviously, the size of an int.I believe I have no other choice than using function overloading! PaulS Brattain Member Posts: 70,812 Karma: 1750[add] Seattle, WA USA Re: Error: cannot use typeid with -fno-rtti #3 Nov 26, 2012, 09:56 pm Quotein fact I want a way to make a function that can handle different types of parameter, like for example:The variable in the typeof() statement is a known type. Switching on the result seems pointl

due to spam. Bug40160 - -fno-rtti vs _GLIBCXX_DEBUG Summary: -fno-rtti vs _GLIBCXX_DEBUG Status: RESOLVED FIXED Alias: None Product: gcc Classification: Unclassified Component: libstdc++ (show other bugs) Version: 4.3.2 Importance: P3 normal Target Milestone: 4.5.0 Assignee: Paolo Carlini URL: Keywords: Depends on: Blocks: Reported: 2009-05-15 14:02 UTC by Jay Foad Modified: 2009-05-18 09:46 UTC (History) CC List: 2 users (show) asl gcc-bugs See Also: Host: Target: Build: Known to work: Known to fail: Last reconfirmed: 2009-05-15 19:34:10 Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Jay Foad 2009-05-15 14:02:50 UTC I get: $ cat s.cpp #include $ g++ -c -fno-rtti -D_GLIBCXX_DEBUG s.cpp In file included from /usr/include/c++/4.3/debug/debug.h:155, from /usr/include/c++/4.3/bits/stl_algobase.h:76, from /usr/include/c++/4.3/bits/char_traits.h:46, from /usr/include/c++/4.3/string:47, from s.cpp:1: /usr/include/c++/4.3/debug/formatter.h: In constructor ‘__gnu_debug::_Error_formatter::_Parameter::_Parameter(const __gnu_debug::_Safe_iterator<_Iterator, _Sequence>&, const char*, __gnu_debug::_Error_formatter::_Is_iterator)’: /usr/include/c++/4.3/debug/formatter.h:218: error: cannot use typeid with -fno-rtti /usr/include/c++/4.3/debug/formatter.h:224: error: cannot use typeid with -fno-rtti /usr/include/c++/4.3/debug/formatter.h: In constructor ‘__gnu_debug::_Error_formatter::_Parameter::_Parameter(const _Type*&, const char*, __gnu_debug::_Error_formatter::_Is_iterator)’: /usr/include/c++/4.3/debug/formatter.h:247: error: cannot use typeid with -fno-rtti /usr/include/c++/4.3/debug/formatter.h: In constructor ‘__gnu_debug::_Error_formatter::_Parameter::_Parameter(_Type*&, const char*, __gnu_debug::_Error_formatter::_Is_iterator)’: /usr/include/c++/4.3/debug/formatter.h:260: error: cannot use typeid with -fno-rtti /usr/include/c++/4.3/debug/formatter.h: In constructor ‘__gnu_debug::_Error_formatter::_Parameter::_Parameter(const _Iterator&, const char*, __gnu_debug::_Error_formatter::_Is_iterator)’: /usr/include/c++/4.3/debug/formatter.h:273: error: cannot use typeid with -fno-rtti /usr/include/c++/4.3/debug/formatter.h: In constr

 

Related content

error cannot use typeid

Error Cannot Use Typeid table id toc tbody tr td div id toctitle Contents div ul li a href Gcc enable cpp rtti a li li a href Enable Rtti a li li a href Gcc Fno-rtti a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies cannot use typeid with -fno-rtti of this site About Us Learn more about Stack Overflow the company how to use typeid in c Business Learn more about hiring developers or