digitalmars.D.learn - Pass reference to void*
- Andre Pany (29/29) Jan 07 2019 Hi,
- Stefan Koch (4/13) Jan 07 2019 From the function declaration &model seems to be the correct
- Andre Pany (9/24) Jan 07 2019 Yes, Open is not null and the strange thing is, everything is
- Stefan Koch (3/18) Jan 09 2019 Might be an calling convention issue?
- Andre Pany (9/30) Jan 09 2019 I finally got it solved. The d coding was right. There was an
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é
Jan 07 2019
On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote: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). [...]From the function declaration &model seems to be the correct thing to use here. Have you checked that Open is not null ?
Jan 07 2019
On Monday, 7 January 2019 at 13:01:57 UTC, Stefan Koch wrote:On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote:Yes, Open is not null and the strange thing is, everything is working fine for DMD on windows. (I call a lot other dll functions afterwards). By switching to LDC the subsequent calls to DLL functions are failing. Thanks. Kind regards André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). [...]From the function declaration &model seems to be the correct thing to use here. Have you checked that Open is not null ?
Jan 07 2019
On Monday, 7 January 2019 at 13:15:44 UTC, Andre Pany wrote:On Monday, 7 January 2019 at 13:01:57 UTC, Stefan Koch wrote:Might be an calling convention issue? Are they declared with extern(Windows) ?On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote:Yes, Open is not null and the strange thing is, everything is working fine for DMD on windows. (I call a lot other dll functions afterwards). By switching to LDC the subsequent calls to DLL functions are failing. Thanks. Kind regards André[...]From the function declaration &model seems to be the correct thing to use here. Have you checked that Open is not null ?
Jan 09 2019
On Wednesday, 9 January 2019 at 18:37:57 UTC, Stefan Koch wrote:On Monday, 7 January 2019 at 13:15:44 UTC, Andre Pany wrote:I finally got it solved. The d coding was right. There was an error in the dll which caused an issue for LDC on Windows. The SO (linux) I got working by chance. The SO has some dependencies to a system package. After installing this package by chance on my Alpine, the cryptic error message disappeared and everything works fine. Kind regards AndreOn Monday, 7 January 2019 at 13:01:57 UTC, Stefan Koch wrote:Might be an calling convention issue? Are they declared with extern(Windows) ?On Monday, 7 January 2019 at 12:19:57 UTC, Andre Pany wrote:Yes, Open is not null and the strange thing is, everything is working fine for DMD on windows. (I call a lot other dll functions afterwards). By switching to LDC the subsequent calls to DLL functions are failing. Thanks. Kind regards André[...]From the function declaration &model seems to be the correct thing to use here. Have you checked that Open is not null ?
Jan 09 2019