July 24, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #20 from Dennis <dkorpel@live.nl> --- (In reply to anonymous4 from comment #16) > Callbacks are more common than reflection-based dll exports. Dplug has them: https://github.com/AuburnSounds/Dplug/blob/5ad0e4c512299fe8ea811ef2b041829f22f02a51/client/dplug/client/dllmain.d#L59 Excel-d has them: https://github.com/kaleidicassociates/excel-d/blob/ea7eb514e39e91fbc637e71a90d72614698dac18/source/xlld/wrap/traits.d#L234 It even mentions how "This used to be a template mixin but even using a string mixin inside fails to actually make it an extern(C) function.". Can you give an example where the proposed behavior would be problematic? -- |
July 24, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #21 from Dennis <dkorpel@live.nl> --- (In reply to Walter Bright from comment #3) > But there's another way you can do it: > > mixin template M() > { > export extern(C) pragma(mangle, "fun") void fun() {} > } > mixin M!(); > > which will work. That works ad-hoc because C mangling is relatively easy, but it asks the user to maintain their own C mangling logic, while the compiler should (and does) provide that. -- |
July 25, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #22 from anonymous4 <dfj1esp02@sneakemail.com> --- (In reply to Dennis from comment #20) > Can you give an example where the proposed behavior would be problematic? Any callback. E.g. https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms633573%28v=vs.85%29 -- |
July 25, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #23 from Dennis <dkorpel@live.nl> --- (In reply to anonymous4 from comment #22) > (In reply to Dennis from comment #20) > > Can you give an example where the proposed behavior would be problematic? > Any callback. E.g. https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ ms633573%28v=vs.85%29 We're specifically looking for a situation where: 1 you have a C-ABI callback-only function 2 but it's not anonymous 3 and it's in a mixin template 4 which is mixed in at global scope 5 and its name clashes with other extern(C) functions / you want to mix it in multiple times Has anyone ever made a mixin template that mixes in a non-anonymous WindowProc resulting in clashing names? So far this situation is only hypothetical, while there are numerous instances of users running into the situation where they want a C-mangled mixin template: DPlug, Excel-D, this issue, https://issues.dlang.org/show_bug.cgi?id=962 and https://issues.dlang.org/show_bug.cgi?id=12575. -- |
July 26, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #24 from anonymous4 <dfj1esp02@sneakemail.com> --- AIU, Manu wants extern(C) to be mangled the same in all situations. -- |
July 26, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 --- Comment #25 from Manu <turkeyman@gmail.com> --- To be fair, what I think is that extern(C) should be mangled the same in all places that it's valid... Which is; global scope. extern(C) doesn't have any precedent outside of global scope, and I just don't care what it does in places where I don't consider it valid. That said, if I had to choose, I'd say be the same everywhere. The odd guy out should be the explicit one. -- |
July 27, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 Ethan Watson <gooberman@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gooberman@gmail.com --- Comment #26 from Ethan Watson <gooberman@gmail.com> --- Bringing this over from my forum post. Here's two code snippets. export extern(C++) void fun() {} pragma( msg, fun.mangleof ); ---- mixin template M() { export extern(C++) void fun() {} } mixin M!(); pragma( msg, fun.mangleof ); ---- Both cases print the exact same mangle - _Z3funv on Linux, ?fun@@YAXXZ on Windows. This illustrates two things: 1) extern(C++) behavior inside mixins is correct. extern(C) behavior is not. 2) pragma( mangle ) is not a catch-all workaround if you are compiling for different architectures/operating systems with different ABIs The Wikipedia article on name mangling[1] goes in to detail on the messy history of mangling C functions in the Windows ecosystem, if you're worried that using C++ as a counter-point is irrelevant. [1] https://en.wikipedia.org/wiki/Name_mangling#C -- |
July 28, 2019 [Issue 20012] export inside mixin doesn't seem to work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #27 from Dlang Bot <dlang-bot@dlang.rocks> --- @dkorpel created dlang/dmd pull request #10236 "Fix issue 20012 - export inside mixin doesn't seem to work" fixing this issue: - fix issue 20012 - export inside mixin doesn't seem to work https://github.com/dlang/dmd/pull/10236 -- |
July 29, 2019 [Issue 20012] extern(C) functions inside template mixins are not mangled as C functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|export inside mixin doesn't |extern(C) functions inside |seem to work |template mixins are not | |mangled as C functions -- |
July 29, 2019 [Issue 20012] extern(C) functions inside template mixins are not mangled as C functions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20012 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- OS|Windows |All -- |
Copyright © 1999-2021 by the D Language Foundation