Certain situations in my code, i end up invoking the function only if that function is defined, or else i should not. How can i achieve this ?
like:
if (func
If you know what library the function you'd like to call is in, then you can use dlsym() and dlerror() to find out whether or not it's there, and what the pointer to the function is.
Edit: I probably wouldn't actually use this approach - instead I would recommend Matiu's solution, as I think it's much better practice. However, dlsym()
isn't very well known, so I thought I'd point it out.