I found the importC feature interesting, I tried the example code (with running the hello world in C using the importC flag) and the compiler threw lots of warnings.
I did it on my Winows 10 machine, it's kinda too late to start it up now and run it but I'll do it tomorrow and post both the code and the error message.
Update:
I did this quickly on my MBP.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
puts("Hello, world!");
return EXIT_SUCCESS;
}
Command:
dmd test.c
Error:
ld: address=0x0 points to section(2) with no content in '/Users/james/.asdf/installs/dmd/2.107.0/dmd2/osx/lib/libphobos2.a[3233](config_a98_4c3.o)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
The solution was that I had to install Visual studio and add the workload (plugin?) "Desktop development with c++".
The only thing needed to be checked was "MSVC v143" and "Windows 11 SDK", the rest is bloat.
After that I had to put the following path from Visual studio "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\Hostx64\x64" into my PATH.
This is because I needed the "cl.exe", "sal.h" and probably a couple of other files to be available to dmd.
(Also, the outdated version of dmd was another factor of the issue)
Finally, the compilation with main.c went smoothly. I had no idea the compiler needed external tooling, I thought it was self sufficient.
> I had no idea the compiler needed external tooling, I thought it was self sufficient.
It used to be self-sufficient. But, we had to give up on our linker because we didn't have the staff to keep a linker up to date, and decided to stop chasing windmills and just use what was available. ImportC, in order to work, needs a preprocessor. We do have our own Standard compliant preprocessor, but it had a major problem. All the C preprocessors predefine a ton of macros (cpp predefines up to 400 macros). Different combinations of compiler switches turn on or off those predefines in poorly and usually undocumented ways. It differs from preprocessor to preprocessor, and was a hopeless nightmare.
So, ImportC uses the C preprocessor of the associated C compiler, and that works like a champ. The downside is you'll need to have that preprocessor installed and on the path.
But it's taking A LONG TIME to become usable.