Skip to content

Commit 98777e8

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 #795
1 parent 0b72c88 commit 98777e8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

hardware/arduino/avr/cores/arduino/Print.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4141

4242
size_t Print::print(const __FlashStringHelper *ifsh)
4343
{
44-
const char PROGMEM *p = (const char PROGMEM *)ifsh;
44+
PGM_P p = (PGM_P)ifsh;
4545
size_t n = 0;
4646
while (1) {
4747
unsigned char c = pgm_read_byte(p++);

hardware/arduino/avr/cores/arduino/WString.cpp

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

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

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

252252
return *this;

hardware/arduino/sam/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)