#include C headers in D code

Atila Neves atila.neves at gmail.com
Tue Apr 10 19:52:38 UTC 2018


On Tuesday, 10 April 2018 at 19:28:09 UTC, Steven Schveighoffer 
wrote:
> On 4/10/18 2:36 PM, Atila Neves wrote:
>
>> 
>> Haha, I remember. I do plan on dealing with emplace_back, but 
>> I have no idea how just yet and I was hoping nobody was going 
>> to call me on it until then. Busted! :P
>> 
>
> I think we all agree you aren't going to instantiate C++ 
> templates in D (and who would want to).

Do we? Do I? :P

(I've actually seriously considered it)

> But since you are using a wrapper to call the compiler, and 
> invoking clang anyway, generating a file to compile which calls 
> the template to generate the object file for the method, and 
> then using the symbol generated to bind to the method might be 
> possible. Of course, you first have to compile your D code to 
> see what templates to generate! So this is another extra step.

That's one of my ideas.

> It could be as easy as generating a mock C++ template for 
> vector, that then has a symbol that d++ recognizes and both 
> replaces with a real call AND helps you figure out what C++ 
> template to generate. -vcg-ast may help here.

The details elude me right now, but that seems to make sense.

> Whatever this is going to be, it ain't going to be fast...

Compiling C++ isn't known to be fast. ;)

It might be possible to limit the damage by confining the C++ 
#includes to one D package or module so it doesn't get rebuilt 
every time.

Atila


More information about the Digitalmars-d-announce mailing list