ImportC and #include files
jmh530
john.michael.hall at gmail.com
Thu May 4 13:34:25 UTC 2023
On Friday, 28 April 2023 at 14:35:25 UTC, bachmeier wrote:
> [snip]
> Compiling with dmd:
>
> ```
> dmd test.c -P-I../../gsl-2.7.1 -I/usr/include
> -I/usr/lib/x86_64-linux-gnu/ -L-lgsl -L-lgslcblas -L-lm
> ```
Alright, I built dmd from source on WSL2. I was able to get a
simple importc program working, but then I got a little stuck
when I try to make it a little more complicated.
What I want to do is the equivalent of `#include <math.h>` from
C, but in a D file. I tried using `import math;` with a small
program that uses it and compiled `dmd file.d -L-lm` but I get a
message that it can't find the math module.
It seemed to do a bit better when I renamed the file to have a .c
ending, but then I would have to put the code back in C terms so
I get errors related to that. When I fix those and replace the
`import math;` with the include, then it works. But this is just
compiling the C code with a D compiler. I want to use the C code
in a D program.
More information about the Digitalmars-d
mailing list