www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18095] New: Add support for pragma(mangle) on alias

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 puremagic.com
          Reporter: doob 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.

--
Dec 17 2017