What is the correct way to check at runtime if a C function exists or not?
This documentation page says that you should check this using if (MyWeakLinkedFunction != NULL)
, but this sample code says that you should use if (&UIApplicationOpenSettingsURLString == NULL) {
.
I currently need this for SecAddSharedWebCredential
and UIApplicationOpenSettingsURLString
.
With a deployment target of iOS 7.0
, it throws no warning neither for the first function nor for the second one, not matter if I add or not the &
.
With a deployment target of iOS 8.0
and with &
added for both, UIApplicationOpenSettingsURLString
throws the warning:
Comparison of address of 'UIApplicationOpenSettingsURLString' not equal to a null pointer is always true
Removing the &
from both function checks, SecAddSharedWebCredential
throws the warning:
Comparison of function 'SecAddSharedWebCredential' not equal to a null pointer is always true
Why aren't both throwing the same warning if both are available since iOS 8.0? And what is the correct way to check this, disregarding the warnings?