The cost of C++ exception handling
Posted: Fri Dec 08, 2023 3:17 pm
I tried to stay away from C++ exception handling on all my ESP32 family work, since legend has it that it's a costly device, in particular on embedded systems.
These days though, I'm writing a driver for an SPI device where a lot of the code is consisting of error handling to check whether the SPI transfer has worked OK (and other edge cases), which is probably the case in 99.99%.
Since I'm writing in C++ anyways and the caller site is so much better if you can just return the payload instead of the error code, I wonder whether I should rather introduce C++ exception handling for that.
These days though, I'm writing a driver for an SPI device where a lot of the code is consisting of error handling to check whether the SPI transfer has worked OK (and other edge cases), which is probably the case in 99.99%.
Since I'm writing in C++ anyways and the caller site is so much better if you can just return the payload instead of the error code, I wonder whether I should rather introduce C++ exception handling for that.