Description
Hi,
Apologies in advance if this is a dumb one, as I am just getting in the process of trying to migrate from using pioarduino to ESP-IDF + VSCode. This might be a dumb and obvious one but I cannot really find anything else similar.
Context :
- ESP-IDF v5.4.2 fresh install + related esp-tools
- Updated VSCode
- Windows 11
I initially started an empty project with ESP-IDF and added ESP32_Display_Panel as a component, without editing the app_main. Upon compilation, I was hit by a bunch of C++ compilation standard errors that seemed to span from esp-lib-utils to esp32_display_panel such as:
...
C:/Users/Martin/Documents/GitHub/ESP32_Display_Panel/examples/esp_idf/lvgl_v8_port/managed_components/espressif__esp-lib-utils/src/log/esp_utils_log.hpp:28:20: error: defaulted 'constexpr bool esp_utils::detail::FixedString<N>::operator==(const esp_utils::detail::FixedString<N>&) const' only available with '-std=c++20' or '-std=gnu++20'
28 | constexpr bool operator==(const FixedString &) const = default;
| ^~~~~~~~
C:/Users/Martin/Documents/GitHub/ESP32_Display_Panel/examples/esp_idf/lvgl_v8_port/managed_components/espressif__esp-lib-utils/src/log/esp_utils_log.hpp:50:22: error: non-type template parameters of deduced class type only available with '-std=c++20' or '-std=gnu++20'
50 | template<FixedString file, int line, FixedString func>
| ^~~~
C:/Users/Martin/Documents/GitHub/ESP32_Display_Panel/examples/esp_idf/lvgl_v8_port/managed_components/espressif__esp-lib-utils/src/log/esp_utils_log.hpp:50:50: error: non-type template parameters of deduced class type only available with '-std=c++20' or '-std=gnu++20'
50 | template<FixedString file, int line, FixedString func>
| ^~~~
ninja: build stopped: subcommand failed.
I thought it might be my dodgy empty template or something escaping my understanding, so I tried to re-compile the lvgl_v8_port ESP-IDF example from the repository. After checking that everything was fairly aligned with menuconfig, the compilation failed again with the same error messages.
I googled a bit and stumbled upon this section of the ESP32 documentation that specifies that the normal compilation standard for this version of the IDF should at least be C++23, which puzzled me even further.
Being confused, I went and edited the CMakeLists.txt file of esp-lib-utils, adding -std=gnu++20 to the target_compile_options section, and despite throwing a lot of warning it seems to successfully compile (I have not tested the functionality of the firmware though):
set(SRC_DIR ./src)
file(GLOB_RECURSE SRCS_C ${SRC_DIR}/*.c)
file(GLOB_RECURSE SRCS_CPP ${SRC_DIR}/*.cpp)
if(ESP_PLATFORM)
idf_component_register(
SRCS ${SRCS_C} ${SRCS_CPP}
INCLUDE_DIRS ${SRC_DIR}
PRIV_REQUIRES pthread
)
else()
set(COMPONENT_LIB esp-lib-utils)
add_library(${COMPONENT_LIB} STATIC ${SRCS_C} ${SRCS_CPP})
target_include_directories(${COMPONENT_LIB} PUBLIC ${SRC_DIR})
endif()
target_compile_options(${COMPONENT_LIB}
PUBLIC
-Wno-missing-field-initializers
-std=gnu++20
)
if(NOT ESP_PLATFORM)
target_compile_definitions(${COMPONENT_LIB} PUBLIC ESP_UTILS_KCONFIG_IGNORE)
endif()
So the question is : is this a bug, or have I missed something ?
I also tried this on Debian on a different machine, and I had the same compilation issue.