How to Use D's ImportC Compiler in a Program
Ali Çehreli
acehreli at yahoo.com
Tue Oct 7 02:20:51 UTC 2025
On 10/6/25 5:56 PM, David T. Oxygen wrote:
> Nothing special.Just a simple Hello-World application.
> ```c
> #include<stdio.h>
> int main(){
> printf("Hello World!\n");
> return 0;
> }
> ```
> Just like the example on the D website.
I put that code into hello.c and compiled. Yes, there are some warning:
$ dmd hello.c
In file included from <command-line>:
/usr/include/dlang/dmd/importc.h:101:8: warning: undefining "__has_feature"
101 | #undef __has_feature
| ^~~~~~~~~~~~~
/usr/include/dlang/dmd/importc.h:104:8: warning: undefining
"__has_extension"
104 | #undef __has_extension
| ^~~~~~~~~~~~~~~
I don't know what they mean. My compiler is this:
$ dmd --version
DMD64 D Compiler v2.109.1
But at least the linked program works:
$ ./hello
Hello World!
> And what in it doesn't matter. The compiler didn't work,no matter what
> code.
Which compiler? Were there any error messages?
> I think if my compiler's version is too low to support ImportC...
Possibly. As a reminder, here is the download page.
https://dlang.org/download.html
Ali
More information about the Digitalmars-d-learn
mailing list