mangling of extern(C) members

evilrat evilrat666 at gmail.com
Fri Jan 11 07:02:01 PST 2013


On Friday, 11 January 2013 at 14:27:35 UTC, Adam D. Ruppe wrote:
>
> A solution to this specific thing is to add C++ constructor 
> mangling to the extern(C++) support.
>
> But I think the general solution is pragma(mangle), that's been 
> discussed before.

there is some problem with C++ constructor(and other special 
functions), on windows it has stdcall format with @0 or @1 at the 
end in place of size, so u can't just get required size for its 
data, also there is NO standard ABI for c++, there is no standard 
calling convention, no way(except by mangling) to detect which 
runtime u will need, imagine how to use c++ RAII classes and 
templates, even if the std::string dropped there is not much use 
for such code.
you'll end up implementing compiler rather then D feature, i 
think Walter already do what's was possible without reinventing 
the compiler.

i had an a idea once to use asm statements to load and call c++ 
ctors or other special functions, it works but totally not 
portable even if would be implemented with effecient CTFE code 
generation...

closest thing one may to do is to use clang lib to get name 
mangling and possibly attach it's codegen or JIT to embedd within 
D code...

sorry if this message is a bit agressive and unclear


More information about the Digitalmars-d mailing list