AUnit
1.5.4
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
|
#include <avr/pgmspace.h>
Go to the source code of this file.
Macros | |
#define | AUNIT_FPSTR(pstr) reinterpret_cast<const __FlashStringHelper *>(pstr) |
The FPSTR() macro is defined on ESP8266 and ESP32, but not on other platforms (e.g. More... | |
#define | AUNIT_F(x) F(x) |
#define | SERIAL_PORT_MONITOR Serial |
Various macros to smooth over the differences among the various platforms with regards to their support for flash strings and the various macros used to create and access them.
On AVR, flash strings are fully supported through the F() and PSTR() macros, and the (const __FlashStringHelper*) pointer. However, the useful FPSTR() macro is not defined.
On Teensy-ARM, flash strings are not supported, but F(), PSTR() and (const __FlashStringHelper*) are defined. The useful FPSTR() macro is not defined.
STM32duino seems to have forked from Teensyduino, so it too has F() and PSTR(), but no FPSTR() macro.
On the ESP8266 platform, flash strings are implemented, and the F(), PSTR() and __FlashStringHelper are defined, but the implementation used to be brittle and fail with obscure errors messages. For a single compilation unit, a flash string could not be defined in both an inline and non-inline contexts (see https://github.com/esp8266/Arduino/issues/3369). This bug was fixed in Dec 2018, so we can use normal F(), PSTR(), and FPSTR() macros on the ESP8266.
On the ESP32, flash strings are not implemented, but the various F(), PSTR() and __FlashStringHelper symbols are defined for compatibility, similar to Teensy-ARM. Unfortunately, the implementation of FPSTR() was incorrectly defined (https://github.com/espressif/arduino-esp32/issues/1371), but the bug was fixed in ESP32 Core 1.0.3 around Sept 2019. Therefore, ESP32 can now use normal F(), PSTR() and FPSTR() macros.
On megaAVR, the F() does not return a (const __FlashStringHelper*), but returns a (const char*). Unfortunately, this breaks AUnit (https://github.com/bxparks/AUnit/issues/56) because a lot of code is generated through macros, which assume that the F() macro returns the correct type.
Previously, AUnit used the F() only for the AVR platforms. But with the various fixes, I think it can be activated for ESP8266 and other platforms. Except for megaAVR whose F() returns the wrong type.
Definition in file Flash.h.
#define AUNIT_FPSTR | ( | pstr | ) | reinterpret_cast<const __FlashStringHelper *>(pstr) |