Can c++ exception handling be enabled?

I’m trying to enable exception handling in the compiler, ideally without modifying the build system.

When I try to compile a source module with exception handling, I get:

error: exception handling disabled, use -fexceptions to enable

 } catch(...)

To the mos.yml I have added:

cxxflags:
  - "-D_GLIBCXX_USE_C99"
  - "-fexceptions" # This should do it, no joy

But no luck.

Thank you…

I figured this out, and I’m posting the answer in case anyone else is interested.

Lots of Googling came up with lots of old and contradictory information, but as of today you do not need the -fexceptions flag. Add this to mos.yml instead:

build_vars:
  ESP_IDF_SDKCONFIG_OPTS: >
    "${build_vars.ESP_IDF_SDKCONFIG_OPTS}"
     CONFIG_CXX_EXCEPTIONS=y
     CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=512

Also, I found many web pages that gave slightly different names for these parameters, but the ones in the sample above are correct.

The emg_pool_size parameter is optional. If its not included it will be set to zero.

Finally, the docs say that enabling exception handling will increase your image size several k. In my case, it as about 29k, which is quite substantial, so I may remove the exception handling from my app.