Closed assumptionsoup closed 2 years ago
I've tried to compile a simple example:
main.cpp
#include <Arduino.h>
#include <cmath>
void setup() {
Serial.begin(115200);
float test = std::round(0.5);
}
void loop() {
}
Results:
> Executing task in folder esp32_burn: C:\Users\jordan\.platformio\penv\Scripts\platformio.exe run <
Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html
PLATFORM: Espressif 32 1.9.0 > Adafruit ESP32 Feather
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: toolchain-xtensa32 2.50200.80 (5.2.0), framework-arduinoespressif32 2.10002.190628 (1.0.2), tool-esptoolpy 1.20600.0 (2.6.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 27 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <EEPROM> 1.0
|-- <FastLED> 3.3.2
| |-- <SPI> 1.0
Compiling .pio\build\featheresp32\src\main.cpp.o
src\main.cpp: In function 'void setup()':
src\main.cpp:7:16: error: 'round' is not a member of 'std'
float test = std::round(0.5);
^
src\main.cpp:7:16: note: suggested alternative:
In file included from C:\Users\jordan\.platformio\packages\framework-arduinoespressif32\cores\esp32/esp32-hal.h:34:0,
from C:\Users\jordan\.platformio\packages\framework-arduinoespressif32\cores\esp32/Arduino.h:35,
from src\main.cpp:1:
C:\Users\jordan\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\newlib/math.h:278:15: note: 'round'
extern double round _PARAMS((double));
^
src\main.cpp:7:9: warning: unused variable 'test' [-Wunused-variable]
float test = std::round(0.5);
^
*** [.pio\build\featheresp32\src\main.cpp.o] Error 1
====================================================== [FAILED] Took 3.87 seconds ======================================================
The terminal process terminated with exit code: 1
This looks to me like c++11 flag isn't working for some reason. Any thoughts?
@assumptionsoup the issue with std::round() looks like an issue which you should file over on https://github.com/espressif/arduino-esp32. There have been a few cases where the C++ std namespace elements were not being picked up correctly due to headers etc.
Thanks. I'll post this issue on espressif, but I don't believe this is an issue with std::, but rather the parts of std that are c++11 specific. This compiles just fine:
#include <Arduino.h>
#include <string>
void setup() {
std::string test = "hello world";
}
void loop() {
}
Most of the C++11 bits should work but you are right in that there may be a few that are namespace polluted by various Arduino headers.
This issue has been automatically marked as stale because it has not had recent activity. Please provide more details or it will be closed if no further activity occurs. Thank you for your contributions.
My code fails to build on windows 10 x64 on PlatformIo 4.0.3 with the following errors:
I've truncated the build log because the rest is similar.
This is my platformio.ini:
I've also tried
build_flags = -std=gnu++11
. Neither work. This code compiles successfully on linux.