PaulStoffregen / Time

Time library for Arduino
http://playground.arduino.cc/code/time
1.24k stars 665 forks source link

Commit f9cef7f breaks platformio SAMD platform #135

Open prices opened 5 years ago

prices commented 5 years ago

Description

After commit f9cef7fb409f5ba281c2a3eb6ce6932dcd4622cd compiling on the SAMD platform gives:

.piolibdeps/Time/DateStrings.cpp: In function 'char monthStr(uint8_t)': .piolibdeps/Time/DateStrings.cpp:76:66: error: 'strcpy_P' was not declared in this scope strcpy_P(buffer, (PGM_P)pgm_read_word(&(monthNames_P[month]))); ^ .piolibdeps/Time/DateStrings.cpp: In function 'char dayStr(uint8_t)': .piolibdeps/Time/DateStrings.cpp:90:61: error: 'strcpy_P' was not declared in this scope strcpy_P(buffer, (PGM_P)pgm_read_word(&(dayNames_P[day]))); ^ *** [.pioenvs/bootloader/libb64/Time/DateStrings.cpp.o] Error 1

Steps To Reproduce Problem

Compile for the SAMD platform. This platform does not have strcpy_P natively.

Steps to fix the problem

Roll back one commit to d4fafb2c06c41a5ddf18f351bf30c5e22e1e7d2e solves the issue.

iKlask commented 5 years ago

The problem is that any platform that doesn't have strcpy_P (non-AVRs) will need it defined as strcpy. They updated it to only define strcpy_P if its an ESP chip, completely ignoring ARDUINO_ARCH_SAMD and any other platforms that don't have strcpy_P defined.

this is what they currently have:

#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
#ifndef strcpy_P
#define strcpy_P(dest, src) strcpy((dest), (src))
#endif
#endif

I'm not sure why it was ever changed from:

#ifndef strcpy_P
#define strcpy_P(dest, src) strcpy((dest), (src))
#endif