Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 18:51:43 UTC, ParticlePeter wrote: On Monday, 22 May 2017 at 14:01:56 UTC, Jerry wrote: IIRC the problem is that it isn't a POD type. ImVec2 has its own default constructor. The problem now is that because it no longer is POD, Window's ABI handles it different and

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 14:01:56 UTC, Jerry wrote: IIRC the problem is that it isn't a POD type. ImVec2 has its own default constructor. The problem now is that because it no longer is POD, Window's ABI handles it different and doesn't put the value in a register. Now with D is that you

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:03:17 UTC, evilrat wrote: On Monday, 22 May 2017 at 11:25:31 UTC, ParticlePeter wrote: Then I am not getting your hack, this function here, does not exist on the C++ side. HACK --- // extern(C++) of course void GetCursorPos(ImVec2* v);

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 22 May 2017 at 14:11:35 UTC, Jerry wrote: are you aware of https://github.com/Extrawurst/DerelictImgui ? Not everyone likes the set of 'derelict' libraries. Especially if you need to statically link to a library. Some of the Derelict packages in the DerelictOrg repo (the SDL2,

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread Jerry via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:58:32 UTC, Stefan Koch wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread Jerry via Digitalmars-d-learn
Note that you also probably need extern(C++) on the struct ImVec2. https://github.com/ParticlePeter/imgui_lib/blob/master/source/imgui/types.d#L84

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread Jerry via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 11:25:31 UTC, ParticlePeter wrote: Then I am not getting your hack, this function here, does not exist on the C++ side. HACK --- // extern(C++) of course void GetCursorPos(ImVec2* v); How is it supposed to work then if there is no

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 08:25:45 UTC, evilrat wrote: On Monday, 22 May 2017 at 08:03:07 UTC, ParticlePeter wrote: No, no, this (other) way around :-), still C++ to D. It actually works btw: HACK --- // original C++ ImVec2 GetCursorPos(); // C++ helper void

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 08:03:07 UTC, ParticlePeter wrote: No, no, this (other) way around :-), still C++ to D. It actually works btw: HACK --- // original C++ ImVec2 GetCursorPos(); // C++ helper void GetCursorPos(ImVec2& result) { result = GetCursorPos(); }

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 07:24:20 UTC, evilrat wrote: On Monday, 22 May 2017 at 06:33:37 UTC, ParticlePeter wrote: On Monday, 22 May 2017 at 01:39:04 UTC, evilrat wrote: And this is actually D problem. In fact first bug report on this thing was dated back to 2014. Still not fixed. Thanks

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 06:33:37 UTC, ParticlePeter wrote: On Monday, 22 May 2017 at 01:39:04 UTC, evilrat wrote: And this is actually D problem. In fact first bug report on this thing was dated back to 2014. Still not fixed. Thanks for your reply, do you have any links to some bug

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:39:04 UTC, evilrat wrote: On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: Probably because the D side is expecting to have the struct returned in a pointer allocated by the callee and then the C++ puts it in regs and BOOM. If you wrap the C++

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-22 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread evilrat via Digitalmars-d-learn
On Monday, 22 May 2017 at 01:27:22 UTC, Nicholas Wilson wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:58:32 UTC, Stefan Koch wrote: On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a

Re: C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 21 May 2017 at 19:33:06 UTC, ParticlePeter wrote: I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct

C++ binding issues with C++ function returning a simple POD struct.

2017-05-21 Thread ParticlePeter via Digitalmars-d-learn
I am statically linking to ImGui [1] on Win 10 x64, quite successfully till this issue came up. The noticed error so far comes when an ImGui function returns an ImVec2, a simple POD struct of two float members. I can use this struct as argument to functions but when it is returned from a