How to detect if a global function exists

I have a program that will allow the optional linking of a certain function.
I know what the function's name will be, but I'm wondering how can check whether the function exists? If it doesn't, the program will just print a pleasant message and exit. If it does exist, the program will call it. Thanks.

Do you own the function or is it imported from an external source?

My plan is to have a program that has the main function in it, but if the program is linked with another piece of Swift code that has e.g. func fubar() in it, then fubar will be called.
If I were coding this in Obj-C, I would just get a list of all the classes that exist, and if one called Fubar did exist, I'd use it.
But for now I'm hoping to detect a function rather than a class.

I mean, Objective-C interoperability is pretty solid, you can implement it with Objective-C and call that.

That seems to require the objective-c runtime, which maybe doesn't exist on Linux which I'm using.

You could call the function dynamically via dlopen and dlsym. The main drawback here is that you’re restricted to C semantics.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple