why do i need an extern(C): here?

WhatMeWorry kheaser at gmail.com
Fri Oct 16 23:12:42 UTC 2020


On Friday, 16 October 2020 at 15:14:03 UTC, Ali Çehreli wrote:
> On 10/15/20 2:42 PM, Ali Çehreli wrote:
>
> > I've recently done the same by calling dlopen() and dlsym()
> > directly. Runtime.loadLibrary documentation says "If the
> library
> > contains a D runtime it will be integrated with the current
> runtime."
> > That would explain why my program seg-faults for my first
> tester with
> > the garbage collector signatures in the function call stack.
>
> Replacing dlopen() with Runtime.loadLibrary() did solve the 
> segfault issue for me.
>
> Ali

Isn't dlopen() for Linux and LoadLibrary() for Windows?  Or are 
you running Windows Subsystem for Linus (WSL) or mingw?


Just to add to the above discussions (for future searchers). I 
also found a demangle() in std.demangle that I used in the 
example below.

alias addSevenFuncSignature = int function(int, int);

addSevenFuncSignature  addSeven;
writeln(addSeven.mangleof);
writeln(demangle(addSeven.mangleof));

_D9onlineapp4mainFZ8addSevenPFiiZi
int function(int, int)* onlineapp.main().addSeven



More information about the Digitalmars-d-learn mailing list