How to use ImportC?

bachmeier no at
Fri Mar 4 00:00:53 UTC 2022

On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote:
> I saw the new feature called ImportC, it's cool to be able to 
> use C code/libraries, but I'm not much experience in C and 
> didn't understand this incomplete documentation: 
> How to use ImportC?

You just add the C files like D files when you compile and import 
them in your D code as you would a D module. At least that is all 
I've been doing. Simple example:


double twice(double x) {
   return 2.0*x;


import foo;
import std.stdio;

void main() {


dmd program.d foo.c

More information about the Digitalmars-d-learn mailing list