IDF 5.0 braking changes to template variadic arguments

vanBassum
Posts: 68
Joined: Sun Jan 17, 2021 11:59 am

IDF 5.0 braking changes to template variadic arguments

Postby vanBassum » Wed Feb 01, 2023 12:04 pm

Hello,

I created a template class that I use for events and callbacks between C++ objects. https://github.com/vanBassum/ESP_Base/b ... c/action.h
This used to work, but now I get compiler errors when I include this into my project.

Code: Select all

In file included from ../../../main/main.cpp:31:
../../../main/event.h:25:50: error: expected ')' before '*' token
   25 |                 ActionHandlerMethod<T, Args...>(T* instance, void(T::*memberFunctionToCall)(Args...))
      |                                                ~ ^
      |                                                  )
../../../main/event.h:45:48: error: expected unqualified-id before 'void'
   45 |                 ActionHandlerFunction<Args...>(void(*functionCall)(Args...))
      |                                                ^~~~
../../../main/event.h:45:48: error: expected ')' before 'void'
   45 |                 ActionHandlerFunction<Args...>(void(*functionCall)(Args...))
      |                                               ~^~~~
      |                                                )
Did something change since IDF 5.0 that would break this code?

Regards

User avatar
mbratch
Posts: 298
Joined: Fri Jun 11, 2021 1:51 pm

Re: IDF 5.0 braking changes to template variadic arguments

Postby mbratch » Wed Feb 01, 2023 8:17 pm

Version 5 of ESP-IDF moved from gcc 8.4.0 (used in ESP-IDF v4.4) to gcc 11.2.0. The compiler's confused about something.

Your error messages point at `event.h` but your link is to `action.h`. Are these the same file with a different name? Or do you have a local `event.h` that includes `action.h`? I think a bit more source context may be needed here to sort it out.

Also, you might want to double check the notes in the ESP-IDF migration guide regarding gcc 8 -> 9 -> 10 -> 11.

vanBassum
Posts: 68
Joined: Sun Jan 17, 2021 11:59 am

Re: IDF 5.0 braking changes to template variadic arguments

Postby vanBassum » Thu Feb 02, 2023 7:49 am

Ah yes, it's the same file with a different name. I should have been more clear on that one. I'll start by checking the migration guide.

I've made a hello world example to demonstrate the problem and eliminate all other code that is not relevant.
https://github.com/vanBassum/ActionTest ... d_main.cpp

EDIT: I did find something in the docs: https://docs.espressif.com/projects/esp ... EARLY_LOGE
I suspect it has something to do with this.

EDIT2: Same code does run on cpp.sh.
https://cpp.sh/?source=%2F%2F+Example+p ... A%0A%0A%0A



Build log

Code: Select all

Run "C:\SysGCC\esp32\2022r1\tools\ninja\1.10.2\ninja.exe flash" in directory "C:\Workspace\ActionTest/build/VisualGDB/Debug" on local computer
C:\SysGCC\esp32\2022r1\tools\ninja\1.10.2\ninja.exe flash
[0/1] Re-running CMake...
-- Building ESP-IDF components for target esp32
-- Checking Python dependencies...
Python requirements are satisfied.
Constraint file: C:\Users\bas\.espressif\espidf.constraints.v5.0.txt
Requirement files:
 - C:\SysGCC\esp32\2022r1\esp-idf\v5.0\tools\requirements\requirements.core.txt
Python being checked: C:\Users\bas\.espressif\python_env\idf5.0_py3.8_env\Scripts\python.exe
-- Project sdkconfig file C:/Workspace/ActionTest/sdkconfig
-- App "hello_world" version: f108b42
-- Adding linker script C:/Workspace/ActionTest/build/VisualGDB/Debug/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_system/ld/esp32/sections.ld.in
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/soc/esp32/ld/esp32.peripherals.ld
-- Components: app_trace app_update bootloader bootloader_support bt cmock console cxx driver efuse esp-tls esp_adc esp_app_format esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_lcd esp_local_ctrl esp_netif esp_partition esp_phy esp_pm esp_psram esp_ringbuf esp_rom esp_system esp_timer esp_wifi espcoredump esptool_py fatfs freertos hal heap http_parser idf_test ieee802154 json log lwip main mbedtls mqtt newlib nvs_flash openthread partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/app_trace C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/app_update C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/bootloader C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/bootloader_support C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/bt C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/cmock C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/console C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/cxx C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/driver C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/efuse C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp-tls C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_adc C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_app_format C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_common C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_eth C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_event C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_gdbstub C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hid C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_http_client C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_http_server C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_https_ota C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_https_server C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_lcd C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_local_ctrl C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_netif C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_partition C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_phy C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_pm C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_psram C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_ringbuf C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_system C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_timer C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_wifi C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/espcoredump C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esptool_py C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/fatfs C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/freertos C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/hal C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/heap C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/http_parser C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/idf_test C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/ieee802154 C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/json C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/log C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip C:/Workspace/ActionTest/main C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mbedtls C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mqtt C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/newlib C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/nvs_flash C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/openthread C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/partition_table C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/perfmon C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protobuf-c C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protocomm C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/pthread C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/sdmmc C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/soc C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/spi_flash C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/spiffs C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/tcp_transport C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/ulp C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/unity C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/usb C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/vfs C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wear_levelling C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wifi_provisioning C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wpa_supplicant C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Workspace/ActionTest/build/VisualGDB/Debug
[1/32] Building C object esp-idf/esp_app_format/CMakeFiles/__idf_esp_app_format.dir/esp_app_desc.c.obj
[2/32] Linking C static library esp-idf\esp_app_format\libesp_app_format.a
[3/32] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D C:\Workspace\ActionTest\build\VisualGDB\Debug\bootloader\esp-idf\esptool_py && python C:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/Workspace/ActionTest/build/VisualGDB/Debug/bootloader/bootloader.bin"
Bootloader binary size 0x6710 bytes. 0x8f0 bytes (8%) free.
[4/30] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/hello_world_main.cpp.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/hello_world_main.cpp.obj 
C:\SysGCC\esp32\2022r1\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -Iconfig -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/newlib/platform_include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/freertos/FreeRTOS-Kernel/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/freertos/esp_additions/include/freertos -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/freertos/esp_additions/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support/include/soc -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support/include/soc/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support/port/esp32/. -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hw_support/port/esp32/private_include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/heap/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/log/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/soc/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/soc/esp32/. -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/soc/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/hal/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/hal/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/hal/platform_port/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/include/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_rom/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_common/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_system/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_system/port/soc -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_system/port/include/private -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/xtensa/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/xtensa/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/include/apps -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/include/apps/sntp -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/lwip/src/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/port/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/lwip/port/esp32/include/arch -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_ringbuf/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/efuse/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/efuse/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/driver/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/driver/deprecated -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/driver/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_pm/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mbedtls/port/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mbedtls/mbedtls/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mbedtls/mbedtls/library -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mbedtls/esp_crt_bundle/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_app_format/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/bootloader_support/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/bootloader_support/bootloader_flash/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_partition/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/app_update/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/spi_flash/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/pthread/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_timer/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/app_trace/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_event/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/nvs_flash/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_phy/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_phy/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/vfs/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_netif/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wpa_supplicant/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wpa_supplicant/port/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wpa_supplicant/esp_supplicant/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_wifi/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/unity/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/unity/unity/src -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/cmock/CMock/src -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/console -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/http_parser -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp-tls -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp-tls/esp-tls-crypto -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_adc/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_adc/interface -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_adc/esp32/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_adc/deprecated/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_eth/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_gdbstub/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_gdbstub/xtensa -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_gdbstub/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_hid/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/tcp_transport/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_http_client/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_http_server/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_https_ota/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_lcd/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_lcd/interface -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protobuf-c/protobuf-c -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protocomm/include/common -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protocomm/include/security -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/protocomm/include/transports -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_local_ctrl/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/esp_psram/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/espcoredump/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/espcoredump/include/port/xtensa -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wear_levelling/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/sdmmc/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/fatfs/diskio -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/fatfs/vfs -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/fatfs/src -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/idf_test/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/idf_test/include/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/ieee802154/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/json/cJSON -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/mqtt/esp-mqtt/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/perfmon/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/spiffs/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/ulp/ulp_common/include -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/ulp/ulp_common/include/esp32 -IC:/SysGCC/esp32/2022r1/esp-idf/v5.0/components/wifi_provisioning/include -mlongcalls -Wno-frame-address  -g -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=C:/Workspace/ActionTest=. -fmacro-prefix-map=C:/SysGCC/esp32/2022r1/esp-idf/v5.0=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -std=gnu++20 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v5.0-dirty\" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -Wno-format -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/hello_world_main.cpp.obj -MF esp-idf\main\CMakeFiles\__idf_main.dir\hello_world_main.cpp.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/hello_world_main.cpp.obj -c ../../../main/hello_world_main.cpp
In file included from ../../../main/hello_world_main.cpp:8:
../../../main/action.h:25:58: error: expected ')' before '*' token
   25 |                         ActionHandlerMethod<T, Args...>(T* instance, void(T::*memberFunctionToCall)(Args...))
      |                                                        ~ ^
      |                                                          )
../../../main/action.h:45:56: error: expected unqualified-id before 'void'
   45 |                         ActionHandlerFunction<Args...>(void(*functionCall)(Args...))
      |                                                        ^~~~
../../../main/action.h:45:56: error: expected ')' before 'void'
   45 |                         ActionHandlerFunction<Args...>(void(*functionCall)(Args...))
      |                                                       ~^~~~
      |                                                        )
../../../main/action.h: In instantiation of 'void ESP_Base::Action<Args>::Bind(void (*)(Args ...)) [with Args = {int}]':
../../../main/hello_world_main.cpp:40:23:   required from here
../../../main/action.h:80:42: error: no matching function for call to 'ESP_Base::ActionHandlerFunction<int>::ActionHandlerFunction(void (*&)(int))'
   80 |                                 action = new ActionHandlerFunction<Args...>(func);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../main/action.h:39:23: note: candidate: 'ESP_Base::ActionHandlerFunction<int>::ActionHandlerFunction()'
   39 |                 class ActionHandlerFunction : public ActionHandler<Args...>
      |                       ^~~~~~~~~~~~~~~~~~~~~
../../../main/action.h:39:23: note:   candidate expects 0 arguments, 1 provided
../../../main/action.h:39:23: note: candidate: 'constexpr ESP_Base::ActionHandlerFunction<int>::ActionHandlerFunction(const ESP_Base::ActionHandlerFunction<int>&)'
../../../main/action.h:39:23: note:   no known conversion for argument 1 from 'void (*)(int)' to 'const ESP_Base::ActionHandlerFunction<int>&'
../../../main/action.h:39:23: note: candidate: 'constexpr ESP_Base::ActionHandlerFunction<int>::ActionHandlerFunction(ESP_Base::ActionHandlerFunction<int>&&)'
../../../main/action.h:39:23: note:   no known conversion for argument 1 from 'void (*)(int)' to 'ESP_Base::ActionHandlerFunction<int>&&'
[5/30] Linking C static library esp-idf\xtensa\libxtensa.a
ninja: build stopped: subcommand failed.
-------------------------------------------------------------
Command exited with code 1
Executable: C:\SysGCC\esp32\2022r1\tools\ninja\1.10.2\ninja.exe
Arguments: flash
Directory: C:\Workspace\ActionTest/build/VisualGDB/Debug
Command-line action failed

========== Project Build Summary ==========
    ActionTest  built in 00:06
========== Build: 0 Succeeded, 1 Failed, 0 Skipped ==========


User avatar
mbratch
Posts: 298
Joined: Fri Jun 11, 2021 1:51 pm

Re: IDF 5.0 braking changes to template variadic arguments

Postby mbratch » Thu Feb 02, 2023 4:27 pm

Thanks for the details. I also had tried the template code on a couple of online compilers and did not have a problem.

I agree that it may have to do with the context in which it is used, per the link you provided.

vanBassum
Posts: 68
Joined: Sun Jan 17, 2021 11:59 am

Re: IDF 5.0 braking changes to template variadic arguments

Postby vanBassum » Mon Feb 06, 2023 8:39 am

Hmm strange, the functional library seems to be working on IDF 5.0.

Code: Select all

std::function<void(int)> moo = [](int i) { ESP_LOGI(TAG, "value = %d", i); };
moo(5);
This seems to be doing exactly the same:

Code: Select all

template<typename _Res, typename... _ArgTypes>
    class function<_Res(_ArgTypes...)>
    : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>,
      private _Function_base
    {
      template<typename _Func,
	       typename _Res2 = __invoke_result<_Func&, _ArgTypes...>>
	struct _Callable
	: __is_invocable_impl<_Res2, _Res>::type
	{ };
	[SNIP]
EDIT: The following code does work:

Code: Select all


template<typename ...Args>
struct MyClass
{
	void(*ptr)(Args...);
	void Test(Args... args)
	{
		ptr(args...);
	}
};



void app_main(void)
{

	MyClass<int> myInstance;
	myInstance.ptr = [](int val) {ESP_LOGI(TAG, "Value = %d", val);};
	
	for (;;)
	{
		myInstance.Test(5);
		vTaskDelay(pdMS_TO_TICKS(1000));
	}
}

vanBassum
Posts: 68
Joined: Sun Jan 17, 2021 11:59 am

Re: IDF 5.0 braking changes to template variadic arguments

Postby vanBassum » Mon Feb 20, 2023 2:51 pm

It's been a while, but I have a workaround that seems to compile. For anyone having similar issues.

The problem seems to be coming from the constructor. So I changed the constructor to a method:

Code: Select all

template<typename T, typename ...Args>
		class ActionHandlerMethod : public ActionHandler<Args...>
		{
		private:
			void(T::*method)(Args...);
			T* methodInstance;
	
		public:
	
			void Bind(T* instance, void(T::*memberFunctionToCall)(Args...))
			{
				method = memberFunctionToCall;
				methodInstance = instance;
			}
	
			void Invoke(Args... args)
			{
				return (methodInstance->*method)(args...);
			}
		};
	
	
	template<typename ...Args>
		class ActionHandlerFunction : public ActionHandler<Args...>
		{
		private:
			void(*func)(Args...);
	
		public:
			void Bind(void(*functionCall)(Args...))
			{
				func = functionCall;
			}
	
			void Invoke(Args... args)
			{
				return (*func)(args...);
			}
		};

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 125 guests