Am 15.08.2014 22:27, schrieb Francesco Cattoglio:
On Friday, 15 August 2014 at 19:53:28 UTC, Walter Bright wrote:
Currently, D supports:
1. C++ function name mangling
2. C++ namespace name mangling
3. C++ class field and vtbl[] layout
4. C++ function calling conventions
But what is missing is name mangling to match C++ templates. This
makes it awkward and tedious to construct a D interface to a C++
template.
Andrei has proposed that D support, for templates declared within an
extern(C++) block, C++ name mangling. This should not be difficult, it
should not break any existing D source code, and will enable limited
interaction with C++ templates from D.
One nice side benefit is that no other language offers such support,
and given the increasing ubiquity of C++ template use, it would give
us a nice leg up.
Do different C++ compilers even mangle template names in the same way? I
remember function and classes mangling being almost standard nowadays,
does this apply to templates, too?
Sure this would add to the "Cool things you can do in D"; do you have
any estimate of the amount of work needed/target release?
On Linux and OSX (and other primarily-GCC/clang-using-platforms)
probably all (common) C++ compilers behave like GCC's g++.
Not sure about different windows compilers, though - but I'd be
surprised if classnames, -fields, vtbl-layouts, function-names and
namespaces were mangled the same but templates not - so either the
problem already exists or there is none. Just guessing, though.
Cheers,
Daniel