Cross-platform dynamic libraries (GNU/Linux, Mac OS X, Windows, ...)
Gregor Richards
Richards at codu.org
Mon Sep 10 10:38:13 PDT 2007
Tomas Lindquist Olsen wrote:
> Gregor Richards wrote:
>
>> Hugues De Keyzer wrote:
>>> Another question: is it safe to directly load a mangled D symbol like
>>> this:
>>>
>>> void* test = dlsym(handle, "_D8mymodule8MyModule4testFZv");
>>>
>>> for static void MyModyle.test()?
>>>
>>> It works, but will it work an all platforms?
>>>
>> The mangling is the same on all platforms, so that should work, but is
>> bound to break eventually. Better would be to make an extern (C) symbol
>> in the loaded library.
>>
>> - Gregor Richards
>
> There is also the .mangleof property.
Yes, that's the reliable cross-platform etc etc way to do it. I was
assuming he didn't necessarily have the .d[i] file corresponding to the
library, but I guess that doesn't make any sense :)
- Gregor Richards
More information about the Digitalmars-d
mailing list