GC seems to crash my C-code function

frame frame86 at live.com
Sun Sep 19 07:21:28 UTC 2021


On Sunday, 19 September 2021 at 02:18:20 UTC, Steven 
Schveighoffer wrote:

>
> ```d
> // option 1
> output[p++] = (ulong(w - e) + 3) % 40;
> // option 2
> output[p++] = cast(char)(((w - e) + 3) % 40);
> ```
>
> Remember also, `char` is C's only way to say "byte". So this 
> may just be data, and not unicode data. You may want to 
> consider using `ubyte` in your translation instead of `char`. 
> But wait until your code is compiling and working as it did in 
> C.
>
> -Steve

Thanks again, good to know how D sees things.
That data is indeed meant to be raw bytes.

Option 2 seems to be always the most reliable one and that kind 
of casts are the only one I did in first place ;-)


More information about the Digitalmars-d-learn mailing list