Skip to content

Commit 4813075

Browse files
matthijskooijmancmaglie
authored andcommitted
Use PGM_P instead of prog_char
On later versions of avr-libc, prog_char is deprecated. In 0acebee the one occurence of prog_char was replaced by "char PROGMEM", which is not entirely correct (PROGMEM is supposed to be an attribute on a variable, not on a type, even though this is how things work in older libc versions). However, in 1130fed a few new occurences of prog_char are introduced, which break compilation on newer libc versions again. This commit changes all these pointer types to use the PGM_P macro from <avr/pgmspace.h>. This macro is just "const char *" in newer libc versions and "const prog_char *" in older versions, so it should always work. References arduino#795
1 parent 7ded66a commit 4813075

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/arduino/WString.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
187187
return *this;
188188
}
189189
len = length;
190-
strcpy_P(buffer, (const prog_char *)pstr);
190+
strcpy_P(buffer, (PGM_P)pstr);
191191
return *this;
192192
}
193193

@@ -247,7 +247,7 @@ String & String::operator = (const char *cstr)
247247

248248
String & String::operator = (const __FlashStringHelper *pstr)
249249
{
250-
if (pstr) copy(pstr, strlen_P((const prog_char *)pstr));
250+
if (pstr) copy(pstr, strlen_P((PGM_P)pstr));
251251
else invalidate();
252252

253253
return *this;

0 commit comments

Comments
 (0)