Operating system:
Windows 10, using Atom with PlatformIO Package.
PlatformIO Version (platformio --version
):
3.5.3
Description of problem
I tried every information found in the platformio docs to remove the build flag ‘-fno-rtti’ from the build process, because I want to use the typeid() operator of C++.
However, it seems to compile with the flag every time, regardless of what I do.
Compiler output:
error: cannot use typeid with -fno-rtti
Serial.printf(typeid(test).name());
The content of platformio.ini
:
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
upload_port = COM11
upload_speed = 921600
build_unflags = -fno-rtti
1 Like
The -fno-rtti
is added as CXX Flag in platform-espressif8266/main.py at develop · platformio/platform-espressif8266 · GitHub
This file is in your .platformio
folder in your Home directory (C:\Users\<Username>\.platformio
). Uncommenting this line with #
makes your code compile (while additionally defining test
as something like struct test { int t; };
)
1 Like
Hm I’ve tried a few ways to remove the -fno-rtti
flag at runtime and all have failed.
platformio.ini
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
extra_scripts = add_rtti.py
main.cpp
#include <Arduino.h>
struct test { int someThing; };
void setup() {
Serial.begin(115200);
Serial.printf("%s", typeid(test).name());
}
void loop() { }
add_rtti.py
Import("env")
print(env)
print(type(env))
print(type(env['CXXFLAGS']))
print("Before")
print(str(env['CXXFLAGS']))
env['CXXFLAGS'].remove("-fno-rtti")
print("After")
print(str(env['CXXFLAGS']))
env.ProcessUnFlags("-fno-rtti")
The script appears to be removing the flag but it’s in the final build command anyways.
No dependencies
<SCons.Script.SConscript.SConsEnvironment object at 0x042F0AD0>
<class 'SCons.Script.SConscript.SConsEnvironment'>
<class 'SCons.Util.CLVar'>
Before
-fno-rtti -fno-exceptions -std=c++11
After
-fno-exceptions -std=c++11
@ivankravets, wasn’t there a case before with -DVECT_TAB_ADDR
where this worked but there were regressions later? Is my script wrong or is something broken? Adding build_unflags = -fno-rtti
has no effect either.
1 Like