3 ms·
There are certain widely accepted norms on how to handle errors in C. It is best to restrain ourselves to "prior art" so that your code is immediately comfortab
by dkrikun 8y ago
There are certain widely accepted norms on how to handle errors in C. It is best to restrain ourselves to "prior art" so that your code is immediately comfortable to read and use for a seasoned C dev.
To list a few: return codes, errno and longjump
- int_19h 8y agoDon't use setjmp/longjmp unless you can guarantee that you own all frames between one and the other (i.e. don't use it as a public error reporting API in a library, for example). They don't play well with C++, and really anything else that needs to unwind the stack. Those who write R extensions in C++ know how messy it can be.
- SamReidHughes 8y agoThe only widely accepted one in that list is return codes.
- Gibbon1 8y ago> a seasoned C dev. To list a few: return codes, errno and longjump A seasoned dev that thinks errno and longjump are good idea's should have retired 25 years ago.
- dkrikun 8y agoYeah, I just tried to be on the more "permissive" side of things. Though per-library errno is being used (zeromq, libuv).