Skip to content

Instantly share code, notes, and snippets.

@njlr
Created May 16, 2017 13:50
Show Gist options
  • Save njlr/c1604bfdca93674ddccccdf107a85866 to your computer and use it in GitHub Desktop.
Save njlr/c1604bfdca93674ddccccdf107a85866 to your computer and use it in GitHub Desktop.
const int ERROR = 1;
const int SUCCESS = 0;
int compute(int input, int* output) {
if (cond(input)) {
return ERROR;
} else {
*output = computeOutput(input);
return SUCCESS;
}
}
// Usage
int output;
int input;
if (int error = compute(input, &output)) {
error_handler(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment