On Monday, 12 February 2018 at 01:27:19 UTC, Walter Bright wrote:
Know what is a heavyweight problem worth our while? Having dmd be able to directly read C .h files, so the poor user does not have to manually translate them.

read directly C++ header files instead of C .h files is what we should aim for. https://github.com/Syniurge/Calypso/ is actually already doing just that and already works in many situations (eg opencv).

Replace the preprocessor in dmc++ with Warp, slice off the back end, and make it a module that dmd can import.

Wouldn't it be nice to support:

    import stdio.h;    // Look, Ma! C headers!

There are some intractable issues, and it may be impossible to get 100% to "it just works", but looking past that it might be a huge win for us.

llvm+clang is a much better approach, guaranteeing compatibility with not just C but also and especially C++ (including current and future C++ standards). Calypso already understands C++ templates, C++ exceptions, can return C++ classes by value (not just by reference), without the restrictions imposed on extern(C++) classes/structs.

```
modmap (C++) "opencv2.hpp";
import (C++) cv.Mat;
// can now use C++ templates, functions, macros etc in D code.
```

There are of course a number of issues left to be ironed out, but it's a much more promising direction than restricting ourselves to C (as done with `cgo` for go). That's where we should focus our efforts as far as interop is concerned.

Reply via email to