On Monday, 17 August 2015 at 02:46:02 UTC, Freddy wrote:
I can't get pragma(mangle) to work on templates(or structs).
[...]

I don't know why but it looks like it only works on functions. Even if a struct is not a template the custom symbol mangle won't be handled:

---
import std.stdio;

pragma(mangle, "a0") class MyClass{}
pragma(mangle, "a1") struct MyStruct{}
pragma(mangle, "a2") void body_func();
pragma(mangle, "a3") struct MyStructh
    { pragma(mangle, "a4") void foo(){}}

void main()
{
    writeln(MyClass.mangleof);
    writeln(MyStruct.mangleof);
    writeln(body_func.mangleof);
    writeln(MyStructh.mangleof);
    writeln(MyStructh.foo.mangleof);
}
---

which outputs:

---
C13temp_019455687MyClass
S13temp_019455688MyStruct
a2
S13temp_019455689MyStructh
a4
---

'a4' being printed and not 'a3' is interesting BTW ;)
I think that the manual is not clear enough about this pragma:

http://dlang.org/pragma.html#mangle

Unless the spec. are more detailed this could be considered as a bug.

Reply via email to