Skip to content

Added emptyString for compatibility with other Arduino cores#19

Merged
pschatzmann merged 1 commit intopschatzmann:mainfrom
MitchBradley:emptyString
Apr 4, 2026
Merged

Added emptyString for compatibility with other Arduino cores#19
pschatzmann merged 1 commit intopschatzmann:mainfrom
MitchBradley:emptyString

Conversation

@MitchBradley
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings April 3, 2026 22:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 emptyString in Arduino.h.
  • Define emptyString in Arduino.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.

Comment on lines 234 to +236
void yield() {}

const String emptyString;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pschatzmann pschatzmann merged commit add5d71 into pschatzmann:main Apr 4, 2026
4 of 5 checks passed
@pschatzmann
Copy link
Copy Markdown
Owner

I was double checking: it seems that only the ESP32 and the RP2040 core from Earle Phil Hower seem to support this...

@MitchBradley
Copy link
Copy Markdown
Contributor Author

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.

@MitchBradley MitchBradley deleted the emptyString branch April 4, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants