Tuesday, May 26, 2020

Better asserts in C with link-time optimization #C #Arduino #Programming

Nerd Ralph discusses how to have the C compiler and linker help with error condition handling:

I’ve been a fan of link-time optimization for several years.  I’ve been a fan of efficient programming for even longer.  I was an early fan of C++ because features like function overloading made it easier to move decisions done at run-time in C to compile-time with C++.  As C++ has become more complex over the decades, I’ve become less of a C++ fan, and appreciate the simplicity of C.

For small embedded systems like 8-bit AVRs and ARM M0, run-time error checking with assert() has minimal usefulness compared to UNIX, where a a core dump will help pinpoint the error location and the state of the program at the time of the error.  Even if the usability problems were solved, real-time embedded systems may not be able to afford the performance costs of run-time error checking.

See the post for the how-to.

No comments:

Post a Comment