On 2012-10-04 01:35, timotheecour wrote:
Is there a way to redefine a extern(C) function in a dynamic load
library? (platform is OSX if that matters).

In a normal D program, I can usually redefine a dynamic load library as
follows: eg, for _d_assertm:
extern(C) void _d_assertm(ModuleInfo* m, uint line){...}
which allows to do stuff before exiting; there are many other use cases.

In a dynamic load library, redefining this (or other extern(C)
functions) doesn't seem to work: the new definition is ignored.

This probably explains the problem I had here:
http://forum.dlang.org/thread/tddzekqtgkqhwjiak...@forum.dlang.org#post-tddzekqtgkqhwjiaknte:40forum.dlang.org

BTW, do you want to replace an function or just calling an existing extern(C) function. In your previous post it seemed like you just wanted to call an existing function. Reading this, it sounds like you want to replace one?

If you want to just call an existing function and you're using "dlopen" you can just get the the function using "dlsym". Even if you don't use "dlopen" now you could probably just add a call to that to load the dynamic library and then use "dlsym".

http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html

--
/Jacob Carlborg

Reply via email to