I'm writing a plug-in application in C and I'm using dlopen/dlsym to load dynamically the "implementation" of some functions. For example I have the following pointer to a function
struct cti_t* (*create)() = 0;
And I load the implementation using the following code:
plugin_handle = dlopen ("xxx.so", RTLD_NOW);
//error checking
create = dlsym(plugin_handle, "cti_create");
//error checking
//call create for the specific implenetation
struct cti_t *dev = create();
The "plug-in" defines the cti_create in the following way
struct cti_t* cti_create(int i) {
printf("Creating device lcl");
//do somenthing with i
return &lcl_cti;
}
So it defines one integer parameter, but everything works without errors. The question is: is it possible to make some argument type verification when the symbol is loaded with dlsym? How can I enforce that the symbols loaded have the signature I expect?