Live data from Hacker News

Plugins in C

eli.thegreenplace.net

11–12 of 12 posts

Re: Plugins in C

#11
post #3

Why not export a struct with function pointers like everyone else? You should take a look at how VST plugins are implemented. You load the dlo, call a function passing in your own struct of application functions and get back a struct of plugin functions. No weird naming conventions needed, easily version-able. Tried and true.

Could you provide an example of this so us neophytes could learn from it?

Re: Plugins in C

#12
post #3

Why not export a struct with function pointers like everyone else? You should take a look at how VST plugins are implemented. You load the dlo, call a function passing in your own struct of application functions and get back a struct of plugin functions. No weird naming conventions needed, easily version-able. Tried and true.

What weird naming conventions? There's only one symbol in each plugin the application knows about, the init_ function, but at least one symbol is usually necessary.

Do you mean the plugins calling PluginManager functions to register hooks? I just wanted to present a simple method without a lot of code. Using structs is an alternative, more convenient in some cases. One problem with it is that it imposes an ABI, while one registration function per hook does not.

Anyhow, this was just a basic example showing how plugins can work. I do plan to explore alternatives in the future, and specifically looking at existing pluggable applications (Apache, for instance)

Post reply on HN