Skip to content

[core] Avoid re-defining C++ round() method#321

Merged
kuba2k2 merged 3 commits intolibretiny-eu:masterfrom
szupi-ipuzs:solve_round_function_conflict
Sep 19, 2025
Merged

[core] Avoid re-defining C++ round() method#321
kuba2k2 merged 3 commits intolibretiny-eu:masterfrom
szupi-ipuzs:solve_round_function_conflict

Conversation

@szupi-ipuzs
Copy link
Copy Markdown
Contributor

I've recently been hit by the same compilation error as described here.
The easiest way to solve this is to only define this macro if the header is included from within pure C code.

Works for me :)

@szupi-ipuzs
Copy link
Copy Markdown
Contributor Author

Sorry the linked issue is not the correct one. Now I can't find it again...

@szupi-ipuzs
Copy link
Copy Markdown
Contributor Author

Still can't find the issue, but here's the compilation log I get without this change:

In file included from /config/.esphome/platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/10.3.1/mutex:39,
                 from .piolibdeps/3ch-usb-relay-1/ESPAsyncWebServer/src/AsyncEventSource.h:11,
                 from .piolibdeps/3ch-usb-relay-1/ESPAsyncWebServer/src/ESPAsyncWebServer.h:1209,
                 from src/esphome/components/web_server_base/web_server_base.h:11,
                 from src/esphome/components/captive_portal/captive_portal.h:11,
                 from src/esphome/components/captive_portal/captive_portal.cpp:1:
/config/.esphome/platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/10.3.1/chrono:360:47: error: macro "round" passed 2 arguments, but takes just 1
  360 |       round(const duration<_Rep, _Period>& __d)
      |                                               ^
In file included from /libretiny/cores/common/arduino/src/Arduino.h:35,
                 from <command-line>:
/libretiny/cores/common/arduino/src/wiring/wiring_compat.h:25: note: macro "round" defined here
   25 | #define round(x)       ((x) >= 0 ? (long)((x) + 0.5) : (long)((x) - 0.5))
      | 

@kuba2k2 kuba2k2 changed the title Don't re-define c++ round() method [core] Don't re-define c++ round() method Sep 19, 2025
@kuba2k2 kuba2k2 changed the title [core] Don't re-define c++ round() method [core] Avoid re-defining C++ round() method Sep 19, 2025
@kuba2k2 kuba2k2 added the bug Something isn't working label Sep 19, 2025
@kuba2k2 kuba2k2 merged commit 1d97f0c into libretiny-eu:master Sep 19, 2025
2 checks passed
@szupi-ipuzs szupi-ipuzs deleted the solve_round_function_conflict branch September 23, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants