Page 1 of 1

How to compile C++ with rtti enabled?

Posted: Tue Mar 13, 2018 12:31 pm
by PaulVdBergh
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

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

Posted: Tue Mar 13, 2018 3:42 pm
by kolban
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.

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

Posted: Tue Mar 13, 2018 3:56 pm
by PaulVdBergh
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

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

Posted: Tue Mar 13, 2018 6:20 pm
by PaulVdBergh
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...