[Issue 20012] export inside mixin doesn't seem to work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 27 11:41:21 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20012

Ethan Watson <gooberman at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gooberman at gmail.com

--- Comment #26 from Ethan Watson <gooberman at 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

--


More information about the Digitalmars-d-bugs mailing list