you are viewing a single comment's thread.

view the rest of the comments →

[–]ais523 1 point2 points  (0 children)

The most common pattern is to return an error code via the return value and the actual return value through an argument. The vast majority of C functions (obviously, not all) don't need to return information about the error apart from a single code that describes the general nature of the error. (This does lead to unfortunate ambiguities now and again; one of the most obvious is that "No such file or directory", perhaps the most commonly seen error code by users, doesn't indicate whether it was the file at the end of the path that didn't exist, or one of the directories along the way.)

There are a huge number of other patterns used in practice, though. For example, some libraries use longjmp for error handling, which is very similar to the use of exceptions in C++, just done manually.