arduino / ArduinoCore-renesas

MIT License
106 stars 72 forks source link

Simple inclusion of <chrono> leads to compilation error #94

Open aentinger opened 1 year ago

aentinger commented 1 year ago

void setup() {

}

void loop() {

}

* Compile the sketch via `arduino-cli compile -b arduino:renesas_portenta:portenta_c33 -v .`.
* Error
```bash
/home/alex/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=200000000 -std=gnu++17 -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 "-DPROJECT_NAME=\"/tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/chrono.ino\"" -DARDUINO_PORTENTA_C33 -DARDUINO_ARCH_RENESAS -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33/defines.txt -DLWIP_DNS=1 -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/tinyusb -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/api/deprecated -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/api/deprecated-avr-comp -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino -I/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33 -iprefix/home/alex/Arduino/hardware/arduino-git/renesas @/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33/includes.txt /tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/sketch/chrono.ino.cpp -o /dev/null
Error while detecting libraries included by /tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/sketch/chrono.ino.cpp
Generating function prototypes...
/home/alex/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=200000000 -std=gnu++17 -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 "-DPROJECT_NAME=\"/tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/chrono.ino\"" -DARDUINO_PORTENTA_C33 -DARDUINO_ARCH_RENESAS -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33/defines.txt -DLWIP_DNS=1 -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/tinyusb -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/api/deprecated -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino/api/deprecated-avr-comp -I/home/alex/Arduino/hardware/arduino-git/renesas/cores/arduino -I/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33 -iprefix/home/alex/Arduino/hardware/arduino-git/renesas @/home/alex/Arduino/hardware/arduino-git/renesas/variants/PORTENTA_C33/includes.txt /tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/sketch/chrono.ino.cpp -o /tmp/arduino/sketches/158652842019AB5611B5802F01A02A76/preproc/sketch_merged.cpp
In file included from /tmp/chrono/chrono.ino:1:0:
/home/alex/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/chrono:266:38: error: macro "abs" passed 2 arguments, but takes just 1
       abs(duration<_Rep, _Period> __d)

Workaround:

-#include <chrono>
+#undef abs
+#include <chrono>

Additional context

Additional reports

facchinm commented 1 year ago

That patch was inherited by https://github.com/arduino/ArduinoCore-mbed/commit/2042db15a90339714f0654416f26c6e389c71aba , which unfortunately doesn't link the underlying issue :disappointed:

AgainPsychoX commented 5 months ago

I wish it was fixed, it's driving me crazy. Worst part is it's not even my code crashing the build:

In file included from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino/mbed/rtos/include/rtos/Kernel.h:27,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino/mbed/rtos/include/rtos/Mutex.h:30,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino/mbed/drivers/usb/include/usb/internal/AsyncOp.h:21,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino/mbed/drivers/usb/include/usb/internal/OperationList.h:22,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\USBCDC.h:26,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\PluggableUSBSerial.h:22,
                 from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\USBSerial.cpp:23:
c:\users\psychox\.platformio\packages\toolchain-gccarmnoneeabi@1.90201.191206\arm-none-eabi\include\c++\9.2.1\chrono:263:38: error: macro "abs" passed 2 arguments, but takes just 1
  263 |       abs(duration<_Rep, _Period> __d)
      |                                      ^
In file included from C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino\USB\USBSerial.cpp:18:
C:\Users\PsychoX\.platformio\packages\framework-arduino-mbed\cores\arduino/Arduino.h:63: note: macro "abs" defined here
   63 | #define abs(x) ((x)>0?(x):-(x))
      |