He Yin Ling 6e05a79536 test: update example and unit tests with new import roles: 6 سال پیش
..
main 6771eead80 examples: use new component registration api 6 سال پیش
CMakeLists.txt 9784df1c3a asio: examples renamed to have consistent binary names when build in make and CMake 7 سال پیش
Makefile cb2876ff4e examples: add C++ exception handling example 7 سال پیش
README.md 47bbb107a8 build system: Use CMake-based build system as default when describing commands 6 سال پیش
example_test.py 6e05a79536 test: update example and unit tests with new import roles: 6 سال پیش
sdkconfig.defaults c5000c83d2 Rename Kconfig options (root) 6 سال پیش

README.md

Example: C++ exception handling

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example demonstrates usage of C++ exceptions in ESP-IDF.

By default, C++ exceptions support is disabled in ESP-IDF. It can be enabled using CONFIG_COMPILER_CXX_EXCEPTIONS configuration option.

In this example, sdkconfig.defaults file sets CONFIG_COMPILER_CXX_EXCEPTIONS option. This enables both compile time support (-fexceptions compiler flag) and run-time support for C++ exception handling.

Example source code declares a class which can throw exception from the constructor, depending on the argument. It illustrates that exceptions can be thrown and caught using standard C++ facilities.

How to use example

Build and Flash

idf.py -p PORT flash monitor

(Replace PORT with the name of the serial port.)

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

app_main starting
In constructor, arg=42
In constructor, arg=0
In destructor, m_arg=42
Exception caught: Exception in constructor
app_main done