-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FPSTR() incorrectly defined in pgmspace.h #1371
Comments
Looks like this bug was introduced in #6. |
Any update on this? (Of course it is easy to work around, but still breaks compatibility.) |
@bxparks |
That was a typo, I meant that type that the following in #define FPSTR(p) ((const char *)(p)) and should be the following instead: #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer)) The purpose of I will send a PR shortly. |
I think the key words here are: |
What's the harm in fixing this? It makes code that was created on a ESP8266 work on the ESP32, without having to sprinkle convoluted conditionals like this in various places: #if defined(ESP8266)
#include <pgmspace.h>
#elif defined(ESP32)
#include <pgmspace.h>
// Clobber the incorrect definition of FPSTR
#undef FPSTR
#define FPSTR(pstr_pointer) \
(reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
#endif |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Verified fixed in 1.0.3-rc2 (and rc3 for completeness). Closing. |
Version 1.0.3 now has this. Quick note that I discovered myself: If you have some old code that was targeted to both ESP8266 and ESP32, and tried to workaround the #if defined(ESP32) && defined(FPSTR)
#undef FPSTR
#define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
#endif You may now get a compiler warning about As far as I can tell, there is no macro that contains the version number of the ESP32 core (e.g. something that resembles The simplest solution that I've found to prevent the compiler warning is to explicitly add a #include <WString.h>
{place workaround code above here} just before the workaround code. |
Hardware:
Board: ESP32 Dev Module
Core Installation/update date: 2018-05-01
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600
Description:
The
FPSTR()
macro in./cores/esp32/pgmspace.h
is incorrectly defined. It is currentlyBut that macro should do a cast to a
(const __FlashStringHelper*)
instead.See https://github.com/esp8266/Arduino/blob/master/cores/esp8266/WString.h#L38
The sketch below works on ESP8266 but fails on ESP32.
The solution is to remove
FPSTR()
frompgmspace.h
and add the following toWString.h
:(where I have redefined
F()
in terms ofFPSTR()
as done in the ESP8266 version of this file).I can send you a PR if you agree that this is the correct solution.
Sketch:
Debug Messages:
The text was updated successfully, but these errors were encountered: