Can we use "ImportC" used yet?

rempas rempas at tutanota.com
Sat Oct 16 14:50:16 UTC 2021


On Saturday, 16 October 2021 at 11:03:06 UTC, jfondren wrote:
>
> I came up with those `#define`s by looking at test_c.c as d 
> complained about it. It includes these functions in the final 
> result:
>
> ```c
> static __uint16_t
> __bswap_16 (__uint16_t __bsx)
> {
>   return (__bsx);
> }
> static __uint32_t
> __bswap_32 (__uint32_t __bsx)
> {
>   return (__bsx);
> }
>  static __uint64_t
> __bswap_64 (__uint64_t __bsx)
> {
>   return (__bsx);
> }
> ```
>
> initially those were defined in terms of compiler intrinsics 
> that d doesn't know about, and since they're not needed for 
> your use, I fixed this in the direction of making them no-ops.
>
> They're part of stdlib.h, probably. What they do is endian 
> swaps, like the stuff in std.bitmanip

Cool! It now makes sense now.

> importC is a new option, but it doesn't make old options go 
> away, and in this specific case an older option would've been 
> less trouble. That's all I'm saying.

Yeah agree, new options are a lot of times not there to make old 
options obsolete and not used. Tho in this case, I think ImportC 
will always makes sense against the old way of doing things. Even 
if you have to do a little bit of work, it will still be nothing 
compared if you had to make manual binding yourself...

Thanks a lot for the help, have an amazing day!!


More information about the Digitalmars-d-learn mailing list