[Issue 18095] New: Add support for pragma(mangle) on alias declarations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 17 17:06:42 UTC 2017


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

          Issue ID: 18095
           Summary: Add support for pragma(mangle) on alias declarations
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: doob at me.com

This allows to override the mangling of a type in an alias declaration as
follows:

pragma(mangle, "foo") alias foo = int;
static assert(foo.mangleof == "foo");
static assert(int.mangleof == "i");

Overriding the mangling of a type in an alias allows for more generic solution
to get the correct mangling of `c_long/c_ulong` for C++ functions. With the
current solution the compiler is looking for a struct with the name
`__c_long/__c_ulong` and special cases the mangling for that particular struct.
Since D doesn't have implicit conversions to structs one are also forced
cast/explicitly construct a `__c_long` struct when calling a function which
uses the `__c_long` type as a parameter. With an alias that's not necessary
anymore.

--


More information about the Digitalmars-d-bugs mailing list