C++ and exception handling
Posted: Wed Mar 01, 2017 1:56 am
Was studying C++ and attempted to deliberately throw an exception to error proof a method I had written. Unfortunately when I use an un-modified ESP-IDF environment for compilation, I get the following compilation error:
The source looks like:
Before I start looking into enabling the "-fexceptions" compilation flags, I am wondering if this feature was disabled on purpose. Is C++ exception throwing/handling not allowed in the ESP-IDF environment?
Code: Select all
19:49:47 **** Build of configuration Default for project target ****
make all
CXX WS2812.o
/home/kolban/esp32/esptest/apps/workspace/target/components/cpp_utils/./WS2812.cpp: In constructor 'WS2812::WS2812(int, uint16_t, int)':
/home/kolban/esp32/esptest/apps/workspace/target/components/cpp_utils/./WS2812.cpp:103:45: error: exception handling disabled, use -fexceptions to enable
throw std::range_error("Pixel count was 0");
^
make[1]: *** [WS2812.o] Error 1
/home/kolban/esp32/esptest/esp-idf/make/component_wrapper.mk:176: recipe for target 'WS2812.o' failed
make: *** [cpp_utils-build] Error 2
/home/kolban/esp32/esptest/esp-idf/make/project.mk:386: recipe for target 'cpp_utils-build' failed
Code: Select all
WS2812::WS2812(int dinPin, uint16_t pixelCount, int channel) {
if (pixelCount == 0) {
throw std::range_error("Pixel count was 0");
}