Added emptyString for compatibility with other Arduino cores#19
Added emptyString for compatibility with other Arduino cores#19pschatzmann merged 1 commit intopschatzmann:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a globally-available emptyString symbol to ArduinoCore-Linux to improve compatibility with Arduino ecosystem libraries (notably ESPAsyncWebServer) that expect the core to provide it.
Changes:
- Declare
emptyStringinArduino.h. - Define
emptyStringinArduino.cpp. - Minor formatting fix for
analogWriteResolution()declaration alignment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ArduinoCore-Linux/cores/arduino/Arduino.h | Adds an emptyString extern declaration for cross-core compatibility. |
| ArduinoCore-Linux/cores/arduino/Arduino.cpp | Adds the emptyString definition in the core implementation TU. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void yield() {} | ||
|
|
||
| const String emptyString; |
There was a problem hiding this comment.
Defining emptyString in Arduino.cpp can force the linker to pull in this entire translation unit when only emptyString is referenced (e.g., from String/third-party libs). This can increase binary size and may also pull in unrelated globals (e.g., WifiMock WiFi behind SKIP_HARDWARE_WIFI). Consider moving the definition to a minimal dedicated .cpp (or wherever the String implementation lives) to keep the dependency surface and linked code small.
There was a problem hiding this comment.
It seems to me that this module is already pretty small, and very likely to be linked anyway since it defines millis() and delay() which are very commonly used. This Arduino core is for use on host machines which typically have lots of memory compared to the footprint of this compilation unit. If the maintainer would like for me to move it to a dedicated .cpp, I will do so, but at first glance it doesn't seem worthwhile.
|
I was double checking: it seems that only the ESP32 and the RP2040 core from Earle Phil Hower seem to support this... |
|
Also LibreTiny https://github.com/search?q=repo%3Alibretiny-eu%2Flibretiny%20emptyString&type=code. Arduino-Emulator support in ESPAsyncWebServer is progressing. The other key component https://github.com/MitchBradley/PosixAsyncTCP is up. |
Many Arduino cores, including ESP32, pico, and libretiny, implement "String emptyString" to save space. ESPAsyncWebServer requires it. I tried adding a private _emptyString to ESPAsyncWebServer but it turned into a mess, so it seems best to implement it here to align with other cores.