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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions