importc and stb
Abdulhaq
alynch4047 at gmail.com
Thu Dec 16 20:04:53 UTC 2021
On Thursday, 16 December 2021 at 19:04:21 UTC, bachmeier wrote:
> On Thursday, 16 December 2021 at 18:38:10 UTC, Elronnd wrote:
>> On Thursday, 16 December 2021 at 14:26:42 UTC, bachmeier wrote:
>>> https://github.com/ibuclaw/importC/blob/main/src/keywords.c.in
>>
>>> #define __builtin_bswap16(x) ((u_int16_t) ((((x) >> 8) &
>>> 0xff) | (((x) & 0xff) << 8)))
>>
>> Oh, my, that's bad. GCC __builtins don't generally evaluate
>> more than once. And this could just be an inline function
>> anyway.
>
> This is why most of us should stay away from C. I honestly
> don't know what that incantation is doing, even though I've
> written a fair amount of C over the years.
:-) it rotates the MSB right 8 places into the LSB, rotates the
LSB left 8 places, and ORs/overlays them both together, to
effectively swap the MSB and LSB bytes
More information about the Digitalmars-d
mailing list