[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 Mathias LANG changed: What|Removed |Added CC||pro.mathias.l...@gmail.com --- Comment #3 from Mathias LANG --- For C `pragma(mangle)` is an easy workaround, however for `extern(C++)`, not only is the mangling non-trivial, but it's currently impossible to do for anything templated, since the mangling depend on template parameters which are not available to `pragma(mangle)`. --
[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 Walter Bright changed: What|Removed |Added Keywords||C++ --
[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 --- Comment #1 from Sobirari Muhomori --- Another option: extern (C++) int __symbol__with(); And let C++ mangler recognize and remove the __symbol__ prefix. Choose your naming convention: alias with_ = __symbol__with; alias _with = __symbol__with; alias _with_ = __symbol__with; alias With = __symbol__with; --
[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 Tim changed: What|Removed |Added CC||tim.dl...@t-online.de --- Comment #4 from Tim --- Using `pragma(mangle)` is also annoying for type names, because every function using the renamed type needs to use the changed mangling. This is for example necessary for `std::function`, because `function` is a keyword in D. It would be nice if you could change the mangled name of a type once and every function using the type gets the changed name automatically. It could look something like this: ``` import core.stdcpp.xutility : StdNamespace; import std.traits; extern(C++, (StdNamespace)) extern(C++, class) pragma(mangle_name, "function") // This type is called function in C++ struct std_function(F) { // ... } extern(C++) void f(ref const std_function!(FunctionTypeOf!(void function())) callback); ``` Currently every function like `f` using `std_function` would need `pragma(mangle)` and the exact mangling depends on operating system and processor architecture. It is possible to generate the correct mangling using CTFE, but this still needs to be done for every function. --
[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 --- Comment #2 from Vladimir Panteleev --- In this particular case, the easiest workaround is to use pragma(mangle), right? I understand that this is more useful for C++ functions, whose mangling is non-trivial. --
[Issue 15587] Enable use of D keywords as identifiers when interfacing to C/C++
https://issues.dlang.org/show_bug.cgi?id=15587 Iain Buclaw changed: What|Removed |Added Priority|P1 |P4 --