importC is not working in GDC?

Iain Buclaw ibuclaw at gdcproject.org
Fri Oct 10 10:52:44 UTC 2025


On Friday, 10 October 2025 at 09:14:15 UTC, felixfxu wrote:
> and compile them by:
> `dmd source/app.d source/importctest.c` OK
>
> `ldc2 source/app.d source/importctest.c` OK,
>
> but with gdc:
>>gdc source/app.d source/importctest.c
> source/app.d:2:8: error: unable to read module ‘importctest’


gdc doesn't compile C files, rather it delegates the compilation 
to gcc-proper in a separate compilation unit.

What you're running is equivalent to:
```bash
gdc -c source/app.d
gcc -c source/importctest.c
gdc source/app.o source/importctest.o
```

Therefore, the D module needs to be told where to find the source 
files, with `-I source`

Mind that C sources need to be preprocessed before handing them 
over to the D compilation unit.
https://gcc.gnu.org/onlinedocs/gdc/ImportC.html


More information about the D.gnu mailing list