Re:Size cost of C++ exception handling on embedded platforms
by usefulcat on Monday May 16, 2016 @11:30AM
(#11706915)
You can indeed live without them. In C++, the trade-off is that you are now responsible for manually writing and maintaining any and all error propagation code, including remembering to check every relevant return value.
[ Parent
| on HN ]
Re:Size cost of C++ exception handling on embedded platforms
by npatrick04 on Monday May 16, 2016 @01:30PM
(#11707932)
Plus you're pretty much screwed on RAII since you cannot return a value from the initializer. So by not using exceptions in C++, you also will often end up requiring a separate init function that can return errors.
Re:Size cost of C++ exception handling on embedded platforms
by humanrebar on Monday May 16, 2016 @12:27PM
(#11707415)
> ...including remembering to check every relevant return value.
To be fair, there are compiler flags to check this. And if not, there are static analysis tools that do the same.
Re:Size cost of C++ exception handling on embedded platforms
by mattkrause on Monday May 16, 2016 @02:08PM
(#11708246)
I was slightly amazed I had never heard of such a thing, but sure enough, it does exist: It's -Wunused-result on gcc (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html). You still need to manually add the warn_unused_result attribute to each function though.
There's also the [[nodiscard]] attribute of c++17.