Skip to content

cores/WString: Add missing __FlashStringHelper implementations#441

Merged
ederjc merged 1 commit into
master-2.x-3.xfrom
bugfix/flash-string-helper-3x
Jun 11, 2026
Merged

cores/WString: Add missing __FlashStringHelper implementations#441
ederjc merged 1 commit into
master-2.x-3.xfrom
bugfix/flash-string-helper-3x

Conversation

@ederjc

@ederjc ederjc commented Jun 10, 2026

Copy link
Copy Markdown
Member

Problem

Using the F() macro with String operations on XMC boards (V3.x) causes linker errors:

undefined reference to `String::String(__FlashStringHelper const*)'
undefined reference to `String::operator=(__FlashStringHelper const*)'
undefined reference to `String::concat(__FlashStringHelper const*)'
undefined reference to `operator+(StringSumHelper const&, __FlashStringHelper const*)'

WString.h declares 5 __FlashStringHelper overloads but WString.cpp was missing all their implementations. This affects any library that uses F() with String (e.g. SimpleSerialShell).

Root Cause

The V3.x branch uses its own cores/WString.h/.cpp (unlike V4.x which uses ArduinoCore-API). The header correctly declared the 5 methods, but the implementations were never added to WString.cpp.

Fix

Added the 5 missing implementations to cores/WString.cpp:

  • String::String(const __FlashStringHelper*)
  • String::copy(const __FlashStringHelper*, unsigned int)
  • String::operator=(const __FlashStringHelper*)
  • String::concat(const __FlashStringHelper*)
  • operator+(const StringSumHelper&, const __FlashStringHelper*)

On XMC (non-AVR), pgmspace.h maps strcpy_P/strlen_P to plain strcpy/strlen, so the implementations are functionally identical to the existing const char* variants.

Testing

Reproduced the 4 linker errors with the stock 3.5.2 install, then confirmed clean compilation after the fix using arduino-cli with Infineon:xmc:XMC1100_Boot_Kit.

Fixes #439

The F() macro produces a const __FlashStringHelper* pointer.
WString.h declared the corresponding constructor, assignment
operator, copy helper, concat overload and StringSumHelper
operator+, but WString.cpp was missing all five implementations,
causing undefined-reference linker errors whenever a library
(e.g. SimpleSerialShell) used F() with String operations.

On XMC (non-AVR) pgmspace.h maps strcpy_P / strlen_P to plain
strcpy / strlen, so the implementations are identical to the
char* counterparts.

Fixes #439

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Julian Eder <julian.eder@infineon.com>
@jaenrig-ifx

Copy link
Copy Markdown
Member

I won't review much in detail. This seems to be available already in the coreAPI -> https://github.com/arduino/ArduinoCore-API/blob/master/api/String.cpp
Therefore this should not be an issue for 4.x ...

@ederjc ederjc merged commit 8f3a70a into master-2.x-3.x Jun 11, 2026
31 checks passed
@ederjc ederjc deleted the bugfix/flash-string-helper-3x branch June 11, 2026 09:15
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