cast a C char array - offset ?
irtcupc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 4 08:09:24 PST 2015
On Monday, 2 February 2015 at 13:40:30 UTC, irtcupc wrote:
> On Monday, 2 February 2015 at 13:34:28 UTC, ketmar wrote:
>> On Mon, 02 Feb 2015 13:32:57 +0000, ketmar wrote:
>>
>>> On Mon, 02 Feb 2015 13:23:23 +0000, irtcupc wrote:
>>>
>>>> my current understanding is that:
>>>> - C: char CompleteInstr[INSTRUCT_LENGTH] is actually a raw
>>>> chunk - D:
>>>> defining the member as char[INSTRUCT_LENGTH] is an error -
>>>> the first
>>>> member of a D array is the .length - first char actually
>>>> stands where
>>>> .length uses to be, which explains the shift.
>>>
>>> nope. fixed length arrays doesn't have dedicated `.length`
>>> member. try
>>> this:
>>>
>>> align(1)
>>> struct _Disasm {
>>> align(1):
>>> ...
>>
>> actually, first align is not necessary at all. i.e.:
>>
>> struct _Disasm {
>> align(1):
>>
>> the difference is that `align` before struct tells how
>> structure should
>> be packed (i.e. when you have `_Disasm[2] arr`). and `align`
>> *inside*
>> struct tells compiler how struct *members* should be packed.
>
> Thx, problem fixed, it works now.
Thx again for your help Ketmar and FG, Thx again for the help in
the other Q too (the one about snn imports), I share the binding,
it's nothing at all but was a fun to do on a off-day...
https://github.com/BBasile/dbeaengine
More information about the Digitalmars-d-learn
mailing list