#include C headers in D code

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 10 19:28:09 UTC 2018


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).

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.

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.

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

-Steve


More information about the Digitalmars-d-announce mailing list