cores/WString: Add missing __FlashStringHelper implementations#441
Merged
Conversation
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>
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 |
jaenrig-ifx
approved these changes
Jun 11, 2026
LinjingZhang
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Using the
F()macro withStringoperations on XMC boards (V3.x) causes linker errors:WString.hdeclares 5__FlashStringHelperoverloads butWString.cppwas missing all their implementations. This affects any library that usesF()withString(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 toWString.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.hmapsstrcpy_P/strlen_Pto plainstrcpy/strlen, so the implementations are functionally identical to the existingconst char*variants.Testing
Reproduced the 4 linker errors with the stock 3.5.2 install, then confirmed clean compilation after the fix using
arduino-cliwithInfineon:xmc:XMC1100_Boot_Kit.Fixes #439