Add ImportC compiler to dmd
Chris Piker
chris at hoopjump.com
Fri May 14 03:03:04 UTC 2021
On Friday, 14 May 2021 at 02:04:47 UTC, Adam D. Ruppe wrote:
> This is already fairly easy to do. dub isn't great at it, but
> you can use a pre-build command in the dub settings to run make
> (or whatever) to build your C parts, then the D parts are built
> and they link seamlessly.
Its easy to do so long as the tools you need are available on
every platform you target. On Linux this trivial, but Windows is
a different beast. Even the download URL for Windows build tools
seems to move around all the time. And once the build tools are
installed, there's no one obvious location for nmake.exe and
cl.exe. Just getting dub to reliably find those tools on some
random person's computer is difficult. On the other hand, dub
can usually find dmd.
Also the dmd+dub distribution is so easy to install that I would
be happy to depend on it just to get away from nmake.exe & cl.exe.
> You can maintain your bindings by hand, or use dstep to build D
> bindings from C headers 90%ish reliably and dtoh to build C
> bindings from D files even better. It isn't actually that hard
> to do, but it can indeed be annoying if there's frequent
> changes to the interface.
Maybe I'm just unlucky (or doing it wrong) but I've never had
dstep or htod work without customizing the output by hand. They
are a good first step and a very welcome time saver but (so far
at least) I wouldn't want to distribute C sources and hope that
header parsing works.
If the dmd distribution came with a real C preprocessor and dmd
gained the ability to compile most C code, I think the end result
would be more user friendly, especially on Windows. I know I'd
try it out.
More information about the Digitalmars-d
mailing list