I'm personally fond of filling an error buffer, but a bit more explicitly than just an int.<p><pre><code> typedef struct APIError {
int code;
char *description;
};
/**
* Returns NULL and fills the error parameter if creation was unsuccessful.
*/
Something APICreateSomething(bool param1, int param2, APIError *error);
</code></pre>
So common execution would be:<p><pre><code> APIError error;
Something something = APICreateSomething(true, 3, &error);
if (error) {
// handle error...
}
</code></pre>
And if the user passed in NULL for the error parameter, then that's their problem, and they won't get error information.