ESP32H2, VSC: Config exception flag not set or ignored.

Riscy00
Posts: 5
Joined: Wed May 15, 2024 7:12 pm

ESP32H2, VSC: Config exception flag not set or ignored.

Postby Riscy00 » 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

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);
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

Riscy00
Posts: 5
Joined: Wed May 15, 2024 7:12 pm

Re: ESP32H2, VSC: Config exception flag not set or ignored.

Postby Riscy00 » Thu May 16, 2024 2:37 pm

I have add this from the top level CMAKE file, which did not work.

# For more information about build system see
# https://docs.espressif.com/projects/esp ... ystem.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(TestH2_Code_5A)

#SDKCONFIG_DEFAULTS

set(SDKCONFIG "$(CMAKE_BINARY_DIR)/sdkconfig")
set(SDKCONFIG_DEFAULTS "sdkconfig.defaults")

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")

Who is online

Users browsing this forum: No registered users and 70 guests