PowerBroker2 / SafeString

This SafeString library is designed for beginners to be a safe, robust and debuggable replacement for string processing in Arduino. Note, this is NOT my work, I am simply hosting it for easy access. The original code belongs to Forward Computing and Control Pty. Ltd.
https://www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html
38 stars 12 forks source link

SafeString causes 'warning "F" redefined' on Teensy 3.2 #66

Closed daanvV closed 1 year ago

daanvV commented 1 year ago

Hello,

When compiling for a Teensy 3.2 I get the following warning:

In file included from R:\XXXXX\teensy_test_safeString\teensy_test_safeString.ino:1:0:
c:\Users\XXXXX\Documents\Arduino\libraries\SafeString\src/SafeString.h:138:0: warning: "F" redefined
 #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
 ^
In file included from C:\Users\XXXX\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\cores\teensy3/Print.h:38:0,
                 from C:\Users\XXX\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\cores\teensy3/Stream.h:24,
                 from C:\Users\XXXXX\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\cores\teensy3/HardwareSerial.h:274,
                 from C:\Users\XXX\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\cores\teensy3/WProgram.h:46,
                 from C:\Users\XXXXX\AppData\Local\Temp\arduino\sketches\6549A712D2E471CF982AC152A4C6C0CD\pch\Arduino.h:6:
C:\Users\XXXXX\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.57.2\cores\teensy3/WString.h:45:0: note: this is the location of the previous definition
 #define F(string_literal) ((const __FlashStringHelper *)(string_literal))
 ^

In Teensy 3.2 the F() macro does nothing, however it is still defined in source code for the code to be compatible with AVR based Teensy boards. So for Teensy 3.2 boards (and some of the other Teensy ARM boards), would it make sense to disable the #define F() in the SafeString.h library?

E.g. something like this (or some other way to recognise ARM 32 bit based boards) in src/SafeString.h :

#if !defined(__MK20DX256__) // Teensy 3.2 
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
#endif

Many thanks,

PowerBroker2 commented 1 year ago

@drmpf

drmpf commented 1 year ago

Thank you for your interest in SafeString. The warning is benign and arises in V4.1.26 and later. the

ifndef F

in SafeString.h which previously suppressed this warning was was commented out the handle the current ESP32 code base

Just ignore the warning, i will 'fix' this in the docs by adding a note to the SafeString webpage.

@PowerBroker2 This can be closed. Thanks