You actually can, by using dlsym(3) to resolve the symbol, cast it to the
appropriate function pointer and call it.
For example:
int (*myfunc)(int, int) = dlsym(RTLD_DEFAULT, myfunc_name);
if (myfunc)
printf(“%d”, myfunc(2, 3));
else
fprintf(stderr, “error: cannot resolve symbol: %s”, myfunc_name);
This works on all POSIX operating systems.
On Oct 18, 2013, at 11:34, Charles Srstka <[email protected]> wrote:
> On Oct 17, 2013, at 9:48 PM, Shane Stanley <[email protected]> wrote:
>
>> is there any way to build a call to a C function on the fly? I mean
>> something like pass a string to a method, and have it call the function of
>> that name?
>
> No. That's an Objective-C feature that's not present in standard C.
>
> Charles
>
>
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]