Make DMD emit C++ .h files same as .di files

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 25 00:00:54 UTC 2019


On 2/24/19 6:24 PM, Manu wrote:
> I've been talking about this for years, and logged this a while back:
> https://issues.dlang.org/show_bug.cgi?id=19579
> 
> Is there anyone interested in or knows how to do this?
> It would really be super valuable; this idea would motivate
> inter-language projects that typically go C++-fist-with-a-D-binding to
> work the other way.
> 
> Creating a pressure to write D-code first because the binding part is
> maintained automatically when you compile is potentially significant;
> gets programmers thinking and writing D code as first-class.
> 
> Idea would be same as emitting .di files, but in this case only
> extern(C)/extern(C++) declarations would be emit to a .h file.
> 
> I could use this to create some nice demos in my office which I think
> would get a few people talking and excited.

Yes that would be fantastic, and something I'd advocated for a long time 
as well. It would be in fact a prime application of the relatively 
recent ability to use dmd as a library. No need to modify the compiler, 
just walk the AST and output the header. Should be a couple hundred 
lines for good effect.

Andrei



More information about the Digitalmars-d mailing list