Pass reference to void*

Andre Pany andre at s-e-a-p.de
Mon Jan 7 12:19:57 UTC 2019


Hi,

I call a C function from a dll (SO on linux). While the following 
code works
fine for DMD on windows, there are strange errors for LDC on 
windows. Also the equivalent code does not work for DMD/LDC on 
linux.
(When calling other functions from the dll and passing the model 
reference, this functions are failing).

Function "Open" gets a path to a model and return via argument 
pModel the reference.
I am not 100% sure whether I call function Open correctly in 
regards to the pModel
argument.

extern(C) nothrow @nogc
{
	alias Model = void*;

	alias da_Open = Status function(const(char)* path, Model* 
pModel);
}

__gshared {
	da_Open Open;
}

Open = cast(da_Open) GetProcAddress(h, "Open");
Model model;
string modelFilePath = "...";

auto status = Open(modelFilePath.toStringz, &model);

Is &model correct?

Kind regards
André


More information about the Digitalmars-d-learn mailing list