I was currently reading this question which shows problems about using void **
as a parameter to return a pointer from a function.
My code mostly has status codes as return values, and now I am looking for alternative ways to return these pointers AND a status code. So I currently see a couple of options, but none of them really make me happy. Probably I am overthinking a little.
// Output status through return value and the pointer through parameter
// - seems to be problematic because it requires casting to void **, which is invalid
int myfunc(void **output);
// Output status through return value, pointer through struct
// - seems to add unnecessary complexity to the interface
struct some_output { void *value };
int myfunc(struct some_output *output);
// Output pointer through return value, status through parameter
// - breaks consistency with other interfaces which always return the status code
void *myfunc(int *status);
Now I am wondering whether there are other, alternative, elegant ways to return pointers and status codes from a function which I did not think about that don't have "drawbacks"?