logoalt Hacker News

zbentleytoday at 3:16 PM1 replyview on HN

In C, errors are usually indicated by a negative return value constant, crashing the program with abort, or setting the errno global (thread-local, but whatever) and expecting callers to check it. Sometimes multiple of those.


Replies

QuercusMaxtoday at 4:05 PM

One reasonably common pattern is to have the return value indicate success / error, and you pass in a pointer to the value which will be mutated if successful.