How to properly printf float (*)() in objective-c?

Viewed 199

I have these two lines of code that which I try to printf on the console, however, in objective-C I get an error saying that: format specifies type 'double' but the argument has type 'float (*)()'

How to properly make this works in Obj-C?

SomeValue = (float (*)())dlsym(someServices, "someMethod");
printf("%f\n", someValue);

Thanks in advance!

1 Answers

someValue in your code is a function pointer, not a value returned from the corresponding function. If you need to print the value returned from that function, simply invoke it:

printf("%f\n", someValue());
//                      ^^

It goes without saying that you have to NULL-check anything that comes from dlsym.

Related