How to fix the mismatch struct size

Arjan arjan at ask.me.to
Wed May 18 06:07:16 UTC 2022


On Wednesday, 18 May 2022 at 04:08:57 UTC, test123 wrote:
> On Tuesday, 17 May 2022 at 10:05:21 UTC, Tejas wrote:
>>
>> Maybe `extern(Windows)` can do something?
>> Also, maybe useful : 
>> https://forum.dlang.org/post/ktntbwppqgbbajpbmrcf@forum.dlang.org
>
> It is extern(C).
>
>
>
>
> On Tuesday, 17 May 2022 at 19:52:23 UTC, Arjan wrote:
>> Do you know how this 'c' part is build? Which compiler and 
>> compiler flags?
>
> Clang with makefile.

As can be observed from your first post,

clang x64 does not pack all the bitields in  the 
`VTermStringFragment` since the size is 24 bytes.

alignment seems to be on address size (64bits 8bytes)

Check the size of the other struct with bitfields `Vterm.mode` in 
the c program and the position of the bitfields if packed.

With that information you should be able to create a matching 
layout in D.

>
>> Than you should be able to 'deduce' the alignment used an 
>> possibly the packing of bitfields.
>
> no alignment is settings from C source file.
>
>
>> Another option is just to figure out the layout at runtime 
>> using a on purpose filled struct from 'c' with 'marker 
>> patterns' in the struct fields.
>
>
> sound like a solution, but not how to do this.




More information about the Digitalmars-d mailing list