Skip to content

Compile error under 2.0.8 if library function explicitly returns const __FlashStringHelper * from F() macro #8108

@avillacis

Description

@avillacis

Board

ESP32

Device Description

YUBOX-Node

Hardware Configuration

No special hardware configuration needed.

Version

v2.0.8

IDE Name

Arduino IDE 2.1.0

Operating System

Fedora Linux 38 x86_64

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

115200

Description

After updating to Arduino-ESP32 2.0.8, the attached sketch will no longer compile, and displays the following error messages:

In file included from /home/alex/.arduino15/packages/esp32-alternatives/2.0.8/hardware/esp32/2.0.8/cores/esp32/Arduino.h:176,
                 from /home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino:1:
/home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino: In function 'const __FlashStringHelper* testfunc()':
/home/alex/.arduino15/packages/esp32-alternatives/2.0.8/hardware/esp32/2.0.8/cores/esp32/WString.h:38:42: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return
 #define F(string_literal) (string_literal)
                                          ^
/home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino:5:10: note: in expansion of macro 'F'
   return F("test");
          ^

exit status 1

Compilation error: exit status 1

The same sketch compiles correctly under previous 2.0.7.

Sketch

#include <Arduino.h>

const __FlashStringHelper * testfunc(void)
{
  return F("test");
}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
}

Debug Message

In file included from /home/alex/.arduino15/packages/esp32-alternatives/2.0.8/hardware/esp32/2.0.8/cores/esp32/Arduino.h:176,
                 from /home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino:1:
/home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino: In function 'const __FlashStringHelper* testfunc()':
/home/alex/.arduino15/packages/esp32-alternatives/2.0.8/hardware/esp32/2.0.8/cores/esp32/WString.h:38:42: error: cannot convert 'const char*' to 'const __FlashStringHelper*' in return
 #define F(string_literal) (string_literal)
                                          ^
/home/alex/programa/practica/arduino/esp32/test-bug-compile-fail-flashstringhelper/test-bug-compile-fail-flashstringhelper.ino:5:10: note: in expansion of macro 'F'
   return F("test");
          ^

exit status 1

Compilation error: exit status 1

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

avillacis

avillacis commented on Apr 22, 2023

@avillacis
Author

Forgot to mention: although the sketch shown above does not explicitly need the F() macro, several libraries available through the Arduino IDE library manager do use this pattern internally. I was bitten by this issue when trying to compile a project using the ESPAsyncWebServer library.

avillacis

avillacis commented on Apr 22, 2023

@avillacis
Author

Apparently the breaking change was introduced in b98255d .

me-no-dev

me-no-dev commented on Apr 23, 2023

@me-no-dev
Member

@dok-net any comments? Please take some action or we will need to revert your PR

dok-net

dok-net commented on Apr 23, 2023

@dok-net
Contributor

@me-no-dev Now people start calling the fix a bug... #7940 details how there is an inconsistency in this core's libraries, on the other hand. Do we want to add __FlashStringHelper wrappers to all ESP32 libs that don't use it now, because it is redundant on ESP32, then? It seems like a lot of work for nothing. This has just been left to rot for far too long, it seems?

dok-net

dok-net commented on Apr 23, 2023

@dok-net
Contributor

Anyway, here's a PR #8111 to fix what originally got in my way.

tueddy

tueddy commented on Apr 23, 2023

@tueddy
Contributor

Same problem compiling this popular RFID lib with 2.0.8:
https://github.com/miguelbalboa/rfid

dok-net

dok-net commented on Apr 23, 2023

@dok-net
Contributor

@tueddy RFID lib (I used the example ReadUidMultiReader.ino) also fixed by #8111.

18 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

      Participants

      @avillacis@tueddy@me-no-dev@dok-net@ryancasler

      Issue actions

        Compile error under 2.0.8 if library function explicitly returns const __FlashStringHelper * from F() macro · Issue #8108 · espressif/arduino-esp32