3 ms·
I don't use C enough to know what the convention is for throwing an error when the function can return a number anyway. You'd have to ask someone else
by voidUpdate 5mo ago
I don't use C enough to know what the convention is for throwing an error when the function can return a number anyway. You'd have to ask someone else
- zbentley 5mo agoIn 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.
- QuercusMax 5mo agoOne 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.
- jamesfinlayson 5mo agoYep, lots of the Windows API does it this way.