3 ms·
And developers never forget to check error codes.
by drysine 9mo ago
And developers never forget to check error codes.
- dan00 9mo agoLooking at code, it‘s easier to spot the missing check for an error code, than a not catched exceptions. Also error codes are part of the signature of a function, which exceptions aren‘t.
- drysine 9mo agoIf you need to wrap each call in try/catch, it's better to use return codes in some form or rethink the approach.
- listeria 9mo agomay I introduce you to the nodiscard attribute[1]? enum (class)? [[nodiscard]] Error { Ok, NoMem, ... }; [1]: https://en.cppreference.com/w/cpp/language/attributes/nodiscard.html https://en.cppreference.com/w/cpp/language/attributes/nodisc...
- drysine 9mo agoC attribute: nodiscard (since C23) [1] https://en.cppreference.com/w/c/language/attributes/nodiscard https://en.cppreference.com/w/c/language/attributes/nodiscar...
- senderista 9mo agoFWIW I’ve been using warn_unused_result in both gcc and clang since about 2020.
- drysine 9mo agoYep, partial remedies are available for quite some time.