Well... using the example from the linked article, it could be made equivalent to your Objective-C snippet, provided the optional passed error-object/struct isn't updated only on errors (as the article suggests), but also can be used to find out if an error happened in the first place.
With a suitable modification, the mentioned example would have to be changed from...
Cutting out the cruft, it's basically what you had suggested to pre pretty Objective-C style ;-)
/* your example */
NSError* error = nil;
[object doSomething: foo error: &error];
if(error){
}
/* article */
libfoo_error_details_t error = NULL;
libfoo_create_widgets(12, &container, &error);
if (LIBFOO_IS_BAD(error)) {
}
EDIT: The linked article already mentions that in the example, error would only be updated if the function returned something unlinke libfoo_success, so one could directly convert to your favourite style keeping these semantics!
With a suitable modification, the mentioned example would have to be changed from...
...to... where LIBFOO_IS_BAD() would be a macro or inline function inspecting the error object/struct, and might be something like Cutting out the cruft, it's basically what you had suggested to pre pretty Objective-C style ;-) EDIT: The linked article already mentions that in the example, error would only be updated if the function returned something unlinke libfoo_success, so one could directly convert to your favourite style keeping these semantics!