Checking the availability of the Runtime API (weak connection) - incorrect behavior at 10.5

I am building a 10.6 application, but for a 10.5 deployment. I want to use Service Management SMJobBless api when the program runs on 10.6, but I will obviously still use the preferred installation tool when starting at 10.5.

I have little reference to the Service Management framework for my executable goal. I tried several code options:

if (SMJobBless != NULL) ...

if (SMJobBless) ...

bool const /* or non-const */ useBlessAPI = SMJobBless != NULL;
if (useBlessAPI) ...

And I even tried using the compiler flags listed in a similar question .

In 10.6 printf("%p %d", SMJobBless, SMJobBless != NULL)(correctly) prints a non-zero pointer value for SMJobBless and 1 for non-empty.

10.5, printf , SMJobBless 0x0, () 1 .

, , - .

Boolean (* const blessAPI) (CFStringRef, CFStringRef, AuthorizationRef, CFErrorRef *) = &SMJobBless;

!

+3
2

, /, , volatile, .

+1

extern Boolean SMJobBless() __attribute__((weak_import)); , . , .

+2
source

Source: https://habr.com/ru/post/1782344/


All Articles