GNOME Bugzilla – Bug 132364
Glib::Module::get_symbol not setting function pointer?
Last modified: 2004-12-22 21:47:04 UTC
I had a conversation with danielk on irc and neither of us could figure out what the problem was here. I want to use Glib::Module in a project of mine, so I was concocting a simple test first. But I still haven't gotten the simple test to work. The problem is with get_symbol(); no matter what I try, it doesn't point my function pointer to the requested symbol. It does return true, and everything else is successful, but my function pointer, which I initialize to NULL, stays NULL. It could very well be a problem with my (crappy) understanding of function pointer syntax -- but I do manage to limp along ok with everything else. So I have 3 tests now. They all basically do the same thing, one with libdl/dlopen()/et al, another with C glib and GModule, and the third with gtkmm's Glib::Module. The first two work great. The problem with the third is beyond me, and trust me, I have tried a *ton* of things. So it was suggested to me to file a bug. The tarball with the 3 tests and makefile is here: http://incise.org:82/~death/pub/module-tests.tgz
Hm, it looks like this is probably something I'm doing wrong, because I managed to get the symbol by doing: void * v; mod.get_symbol("cos", v); And then this works ok: cerr << (*(double_double_func_t)v)(1.2) << endl;
Yes, you should not expect a cast like that to work. function pointers are strange and compiler-dependent.