C++ interface problem
extrawurst via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Apr 27 04:00:22 PDT 2015
On Monday, 27 April 2015 at 07:37:23 UTC, Laeeth Isharc wrote:
> On Sunday, 26 April 2015 at 15:49:46 UTC, extrawurst wrote:
>> I hope someone can tell me where my bug is.
>> I am linking to a dynamic library with C++ interfaces:
>>
>> ```
>> //alias S = ulong;
>> struct S
>> {
>> ulong data;
>> }
>>
>> extern(C) I getI();
>>
>> extern(C++) interface I
>> {
>> void foo();
>> S bar();
>> }
>> ```
>>
>> now the question is why does it crash to access bar() in both
>> cases? (using alias aswell as the struct)
>> The C++ class S is a POD class (it contains only 64bits of
>> data and is compiled byte aligned)
>> The call to bar() from D just crashes on win32, the interface
>> works fine on osx 64bit.
>> Any help would be welcome! Is this even possible to solve ? I
>> have no access to the library code so I am not able to build
>> the C++ lib with like DMC or something...
>
> Long always 64 bit in D but varies with architecture in C. See
> here:
> http://wiki.dlang.org/Converting_C_.h_Files_to_D_Modules
>
> Core.stdc.config has alias for the C type that you can use in
> place of long.
Thought about that too and tried uint aswell. does not work
either..
More information about the Digitalmars-d-learn
mailing list