I use an external C library in my C++ program and the library uses a callback function, that must return void*. The library checks if return value is not NULL, which means success.
So what is the best way to tell it that all is fine?
I use:
return reinterpret_cast<void*>(1);
but it looks ugly…
Edit: thanks for reply, i will stay with this:
static int success;
return &success;
Strictly speaking,
staticis probably not required, but it feels a bit gauche to return a pointer to a local that’s going out of scope.EDIT: Note @sharptooth’s comment. Strictly speaking,
staticis required.