Intro to calling C libraries

Ian ian at iangarcia.net
Thu Feb 20 21:10:29 UTC 2025


On Thursday, 20 February 2025 at 21:05:40 UTC, Lance Bachmeier 
wrote:
>
> Normally, you should be using ImportC. Look at the quick 
> example from the spec: 
> https://dlang.org/spec/importc.html#examples
>
> The first line of hello.c looks like this:
>
> ```
> #include <stdio.h>
> ```
>
> When ImportC compiles a C file, it runs the C preprocessor and 
> does all the including you need. But rather than stdio.h, you 
> can compile a C file that includes all the C headers you need. 
> That's all you have to do. You can use the usual preprocessor 
> calls like -I by using the -P switch: 
> https://dlang.org/spec/importc.html#auto-cpp
>
> Assuming ImportC works with your C headers, that's everything 
> you need.

Perfect! I'll try this. Thank you.




More information about the Digitalmars-d-learn mailing list