Bug 18095 – Add support for pragma(mangle) on alias declarations

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-12-17T17:06:42Z
Last change time
2024-12-13T18:55:38Z
Assigned to
No Owner
Creator
Jacob Carlborg
Moved to GitHub: dmd#19350 →

Comments

Comment #0 by doob — 2017-12-17T17:06:42Z
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.
Comment #1 by doob — 2017-12-17T20:21:41Z
Comment #2 by robert.schadek — 2024-12-13T18:55:38Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19350 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB