F() macro storage behavior in Arduino AVR core 2.0.x for Print function arguments
0 reputation · 10 Mar 2025, 19:48 UTC
When migrating sketches from Arduino AVR core 1.8.x to 2.0.x, the role of the F() macro for string literals passed to Print::print() becomes unclear. The documented purpose of F() is to keep string literals in flash memory rather than copying them to RAM, which matters on AVR boards with only a few kilobytes of SRAM. However, it is not well documented whether newer core or toolchain versions change how plain literals are placed, or whether the macro remains strictly necessary in all cases.
The goal is to establish a reliable rule for when F() is required across core versions, and to understand the interaction with functions that expect RAM-resident char* pointers, where flash strings can cause compilation errors. Compatibility with PROGMEM-based approaches for larger constant data is also a consideration.
Specific open points:
- Does AVR core 2.0.x change literal placement for
Printoverloads compared to 1.8.x, or mustF()always be explicit? - What is the recommended way to verify at compile time or runtime whether a given literal resides in flash versus RAM?
- Which core version introduced any such behavior change, and is it documented in release notes?