Skip to content

Commit 374d164

Browse files
committed
Fix for building for ESP8266 core
The use of PROGMEM for some global variables in parser.h caused GCC to report a section type conflict when building for ESP8266 as a result of the ESP8266 core's simulation of PROGMEM (which is in fact AVR specific). See esp8266/Arduino#2078. Fixed by disabling these uses of PROGMEM when building for ESP8266. As ESP8266 has more RAM than AVR chips (80K vs. 2K for the ATMega328p) the resulting increase in RAM use is not a major concern.
1 parent cf71aab commit 374d164

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/dsmr/parser.h

+13
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ struct ParsedData<> {
8383
// Do not use F() for multiply-used strings (including strings used from
8484
// multiple template instantiations), that would result in multiple
8585
// instances of the string in the binary
86+
// The use of PROGMEM in this place will cause GCC to report a section type
87+
// conflict when building for the ESP8266 core.
88+
#ifndef ARDUINO_ARCH_ESP8266
8689
static constexpr char DUPLICATE_FIELD[] PROGMEM = "Duplicate field";
90+
#else
91+
static constexpr char DUPLICATE_FIELD[] = "Duplicate field";
92+
#endif
8793

8894
/**
8995
* General case: At least one typename is passed.
@@ -156,8 +162,15 @@ struct StringParser {
156162
// Do not use F() for multiply-used strings (including strings used from
157163
// multiple template instantiations), that would result in multiple
158164
// instances of the string in the binary
165+
// The use of PROGMEM in this place will cause GCC to report a section type
166+
// conflict when building for the ESP8266 core.
167+
#ifndef ARDUINO_ARCH_ESP8266
159168
static constexpr char INVALID_NUMBER[] PROGMEM = "Invalid number";
160169
static constexpr char INVALID_UNIT[] PROGMEM = "Invalid unit";
170+
#else
171+
static constexpr char INVALID_NUMBER[] = "Invalid number";
172+
static constexpr char INVALID_UNIT[] = "Invalid unit";
173+
#endif
161174

162175
struct NumParser {
163176
static ParseResult<uint32_t> parse(size_t max_decimals, const char* unit, const char *str, const char *end) {

0 commit comments

Comments
 (0)