In this post, 1 CMake topic:
- how to enable c++ Exception Handling and RTTI (Run-Time Type Information)
Both c++ constructs come with a cost, the biggest being that they requires more memory. In most microcontroller configurations, these options are turned off by default.
They are useful language components though. And the Pico has enough resources to support both.
You use the CMake CMakeList.txt file to enable them. If you use the Pico Project Generator to create a new project, two checkboxes switch on these options.
If you write your own CMake files, or want to update an existing project, you add these lines to CMakeList.txt:
set(CMAKE_CXX_STANDARD 20) project(<yourproject> C CXX ASM) set(PICO_CXX_ENABLE_EXCEPTIONS 1) set(PICO_CXX_ENABLE_RTTI 1)
Whether you want to use c++ and these options is an architectural choice. As always, there are pros and cons. And you have to balance limited resources. But if you decide that these options are fit for your project, this is how to enable them.
references:
- GeeksForGeeks: Exception Handling
- GeeksForGeeks: RTTI (Run-Time Type Information)







