ESP32H2, VSC: Config exception flag not set or ignored.
Posted: Wed May 15, 2024 7:21 pm
ESP32-H2 ESP-IDF 5.2.1 C++ coding practice with exception
I have reviewed the https://github.com/espressif/esp-idf/tr ... exceptions and ESP-IDF programming manual.
I have added simple exception statement
it throw out compiler error:
E:/016_Work_ESP32/010_Example/BlinkH2_ESPIDF/WorkspaceH2/TestH2_Code_5A/main/main.cpp: In function 'void testException_1A()':
E:/016_Work_ESP32/010_Example/BlinkH2_ESPIDF/WorkspaceH2/TestH2_Code_5A/main/main.cpp:221:61: error: exception handling disabled, use '-fexceptions' to enable
221 | throw std::invalid_argument("Number2 cannot be zero");
I have following the documentation where I set
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.2.1 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32h2"
# Enable C++ exceptions and set emergency pool size for exception objects
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=1024
in skdconfig.default
But it did not remove the error; I am running out of ideas on how to fix this. The config menu does not have the option to set/clear exceptions, so I wonder if this is supported or not.
Thanks
I have reviewed the https://github.com/espressif/esp-idf/tr ... exceptions and ESP-IDF programming manual.
I have added simple exception statement
Code: Select all
#include <stdexcept>
//using std::invalid_argument
//==================================== Exception test
void testException_1A(void)
{
double number1 = 10.0;
double number2 = 20.0;
double result;
if (number2 == 0.0) // Take care, it does not alwat work
{
throw std::invalid_argument("Number2 cannot be zero");
}
result = number1/number2;
fmt::print("result ={}\n",result);
E:/016_Work_ESP32/010_Example/BlinkH2_ESPIDF/WorkspaceH2/TestH2_Code_5A/main/main.cpp: In function 'void testException_1A()':
E:/016_Work_ESP32/010_Example/BlinkH2_ESPIDF/WorkspaceH2/TestH2_Code_5A/main/main.cpp:221:61: error: exception handling disabled, use '-fexceptions' to enable
221 | throw std::invalid_argument("Number2 cannot be zero");
I have following the documentation where I set
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.2.1 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32h2"
# Enable C++ exceptions and set emergency pool size for exception objects
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=1024
in skdconfig.default
But it did not remove the error; I am running out of ideas on how to fix this. The config menu does not have the option to set/clear exceptions, so I wonder if this is supported or not.
Thanks