How to Use D's ImportC Compiler in a Program
David T. Oxygen
TKC847567 at outlook.com
Sun Oct 12 10:49:33 UTC 2025
On Wednesday, 8 October 2025 at 02:00:59 UTC, Steven
Schveighoffer wrote:
>>>> Who knows why? I'm waiting for your answer.
>>>
>>> Which D compiler, and version?
>>
>> I used DMD 2.110.1 when compiling. Now I know it should be
>> able to compile C files.
>
> 2.110.1 does not exist. Where did you get this compiler from?
> Make sure you only install official compilers.
>
> https://dlang.org/changelog/index.html
>
> When I use 2.111.0, it does work for me:
>
> ```
> steves at homebuild:~$ dmd --version
> DMD64 D Compiler v2.111.0
> Copyright (C) 1999-2025 by The D Language Foundation, All
> Rights Reserved written by Walter Bright
> steves at homebuild:~$ cat hello.c
> #include<stdio.h>
> int main(){
> printf("Hello World!\n");
> return 0;
> }
> steves at homebuild:~$ dmd hello.c
> steves at homebuild:~$ echo $?
> 0
> steves at homebuild:~$ ./hello
> Hello World!
> steves at homebuild:~$
> ```
>
> -Steve
--
Thank you for your help,but I still haven't solved my problem.
I reinstalled DMD 2.111.0 today,it's the newest relaese version.
However,the compiler still keep silent when compiling `dmd
hello.c`...(If it can't compile,at last it should complain,all
right? But it did nothing...)
But if I speak `dmd --version` it will tell me:
`DMD64 D Compiler v2.111.0
Copyright (C) 1999-2025 by The D Language Foundation, All Rights
Reserved written by Walter Bright`
And it can compile a normal D file which doesn't import a C file.
If the D file imports a C file,the compiler will still keep
silent...
Oh no that's too bad. I wonder if there may be anything wrong
with my computer...
More information about the Digitalmars-d-learn
mailing list