digitalmars.D.learn - Can't pass [] to extern function object method
- frame (9/9) Nov 16 2020 I have a DLL in D-code which returns an object and want to pass a
- Jack (3/13) Nov 16 2020 What is the function prototype like and how are you declaring
- frame (13/15) Nov 16 2020 The struct is very simple, it contains:
- frame (4/8) Nov 18 2020 I found the "bug". It was caused by a debug {} statement within a
- Bastiaan Veelo (5/8) Nov 18 2020 Were the DLL and main program built in different modes
- frame (6/14) Nov 19 2020 No, but the DLL was compiled with -debug flag which enables an
I have a DLL in D-code which returns an object and want to pass a struct S[] to a member function of that object. The first element is passed correctly, the rest is just garbage. In fact the next item is just a single byte with value 0x11 following some 0x00. It doesn't matter if I'm using S[], S[]* or S* with .ptr. The length of the array is correct but the data isn't except the first item. Is this a trap because of extern function? How can I access the next item? Increasing the pointer is equivalent with S[1].
Nov 16 2020
On Monday, 16 November 2020 at 21:31:44 UTC, frame wrote:I have a DLL in D-code which returns an object and want to pass a struct S[] to a member function of that object. The first element is passed correctly, the rest is just garbage. In fact the next item is just a single byte with value 0x11 following some 0x00. It doesn't matter if I'm using S[], S[]* or S* with .ptr. The length of the array is correct but the data isn't except the first item. Is this a trap because of extern function? How can I access the next item? Increasing the pointer is equivalent with S[1].What is the function prototype like and how are you declaring that struct?
Nov 16 2020
On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote:What is the function prototype like and how are you declaring that struct?The struct is very simple, it contains: struct S { SysTime a; ulong b; double c; ubyte[] d; string e; } And I tried: bool foo(S[] params); // passing a S[] bool foo(S[]* params); // passing a &S[] bool foo(S* params); // passing a S.ptr
Nov 16 2020
On Monday, 16 November 2020 at 22:22:42 UTC, frame wrote:On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote:I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context.What is the function prototype like and how are you declaring that struct?The struct is very simple, it contains:
Nov 18 2020
On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote:I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context.Were the DLL and main program built in different modes (debug/release)? Then this problem is understandable. Otherwise I find this surprising, and probably worth a bug report? — Bastiaan.
Nov 18 2020
On Thursday, 19 November 2020 at 07:46:20 UTC, Bastiaan Veelo wrote:On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote:No, but the DLL was compiled with -debug flag which enables an additional member that the main program cannot see. I think that is the explaination. In fact the flag was not set on the main program.I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context.Were the DLL and main program built in different modes (debug/release)? Then this problem is understandable. Otherwise I find this surprising, and probably worth a bug report? — Bastiaan.
Nov 19 2020