August 27, 2014 Re: Interfacing D with C and C++ | ||||
---|---|---|---|---|
| ||||
Posted in reply to Scott Wilson | On 8/23/2014 3:46 PM, Scott Wilson wrote: > 1. What is the current support for calling C/C++ free functions from D? What > level of mangling is supported? What data types can be passed without > translation from D to C/C++? D's native types can be used to call C/C++ free functions directly without translation. Structs are the same. > 2. How about template functions? Is it possible to call a C++ template function > from D? Yes. > 3. How can a C++ object be used from D? Can C++ methods be called from D? The > question applies to value types - no virtuals - and polymorphic types with > virtuals, inheritance etc. And of course simple C structs. Simple structs can be passed back and forth without modification. Classes with single inheritance can be passed by reference back and forth. > 4. How about template objects? One issue is that many C++ interfaces pass > std::string and std::map<..., ...> as parameters. How feasible is to manipulate > such objects in D? Check out the following update to the compiler https://github.com/D-Programming-Language/dmd/pull/3895 which makes it possible for D to interface with C++ std functions. > 5. How about the other way? Can a C/C++ function call a D function? Yes. |
Copyright © 1999-2021 by the D Language Foundation