Thread overview | |||||
---|---|---|---|---|---|
|
February 14, 2017 pragma(mangle,"name") for a type? | ||||
---|---|---|---|---|
| ||||
Attachments:
| How do I define pragma(mangle,"name") for a type? Use case: I'd like to avoid the complications involved in https://github.com/dlang/druntime/pull/1316/files [Addition of C++ std::string, std::vector to D #1316] by directly defining the desired mangle for a c++ std::string (+ other similar use cases): ``` pragma(mangle, "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE") struct string_cpp; extern(C++, ns){ void fun1(string_cpp*a); string_cpp fun2(); void string_cpp fun3(const ref string_cpp a); } ``` The problem is that this mangles fun1 as _ZN2ns4fun1EP10string_cpp , ie, using "string_cpp" instead of "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE" for the `a` argument of fun1, thus ignoring (silently!) the pragma(mangle). |
February 14, 2017 Re: pragma(mangle,"name") for a type? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | Side note: Microsoft uses a different C++ mangling... |
February 15, 2017 Re: pragma(mangle,"name") for a type? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timothee Cour | On Tuesday, 14 February 2017 at 11:15:26 UTC, Timothee Cour wrote:
> How do I define pragma(mangle,"name") for a type?
>
> Use case:
> I'd like to avoid the complications involved in
> https://github.com/dlang/druntime/pull/1316/files [Addition of C++
> std::string, std::vector to D #1316]
> by directly defining the desired mangle for a c++ std::string (+ other
> similar use cases):
>
> ```
>
> pragma(mangle, "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE")
> struct string_cpp;
>
> extern(C++, ns){
> void fun1(string_cpp*a);
> string_cpp fun2();
> void string_cpp fun3(const ref string_cpp a);
> }
>
> ```
>
>
> The problem is that this mangles fun1 as _ZN2ns4fun1EP10string_cpp , ie, using "string_cpp" instead of "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE" for the `a` argument of fun1, thus ignoring (silently!) the pragma(mangle).
I've got a use case similar to this: declaring and using named opaque types in LLVM IR to support images for DCompute OpenCL support. If I could leverage pragma mangle instead that would be awesome!
|
Copyright © 1999-2021 by the D Language Foundation