How to compile C++ with rtti enabled?

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

How to compile C++ with rtti enabled?

Postby PaulVdBergh » Tue Mar 13, 2018 12:31 pm

Hi all,

In my code I us

Code: Select all

class Base {};
class Derived : public Base {};
Base* base = new Derived();
Derived* derived = dynamic_cast<Derived*>(base)
. To compile this, I need to enable rtti (Real Time Type Information) in the compiler options. Where can I enable this option (in eclipse IDE) ?

Thanks,
Paul

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: How to compile C++ with rtti enabled?

Postby kolban » Tue Mar 13, 2018 3:42 pm

In your main folder, you will find a file called component.mk. You can edit this and add compiler flags. If I remember correctly:

CFLAGS += ... flags for C compiler
CXXFLAGS += ... flags for C++ compiler

See ... Component Makefiles.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

Re: How to compile C++ with rtti enabled?

Postby PaulVdBergh » Tue Mar 13, 2018 3:56 pm

thanks for your reply.

However, the -fno-rtti is already set (or is default behaviour), I have to remove it somewhere...
Or is it another flag to enable rtti?

Thanks,
Paul

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

Re: How to compile C++ with rtti enabled?

Postby PaulVdBergh » Tue Mar 13, 2018 6:20 pm

Ok, I added

Code: Select all

CXXFLAGS += -frtti
to the component.mk file and now it compiles. I was confused by only finding -fno-rtti in the gnu gcc documentation, nothing about -frtti documented...

Who is online

Users browsing this forum: Baidu [Spider] and 69 guests