Bug 22682 – `pragma(mangle)` does not work for nested functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-01-16T22:25:01Z
Last change time
2023-09-08T10:14:27Z
Keywords
pull
Assigned to
No Owner
Creator
Basile-z
See also
https://issues.dlang.org/show_bug.cgi?id=15843, https://issues.dlang.org/show_bug.cgi?id=17638

Comments

Comment #0 by b2.temp — 2022-01-16T22:25:01Z
## test case ``` void main() { pragma(mangle, "puts") extern(C) static int puts(const char*); puts("test"); } ``` ## output /tmp/temp_7FF8B2F14490.d:2:5: Error: unrecognized `pragma(mangle)` /tmp/temp_7FF8B2F14490.d:4:5: Error: undefined identifier `puts`
Comment #1 by b2.temp — 2023-09-06T19:32:13Z
A better test case, as in the first the final intention is a bit more complex. ```d void main() { pragma(mangle, "main.v") void v(){} } ```
Comment #2 by dlang-bot — 2023-09-06T20:47:00Z
@SixthDot created dlang/dmd pull request #15582 "fix issue 22682 - `pragma(mangle)` does not work for nested functions" fixing this issue: - fix issue 22682 - `pragma(mangle)` does not work for nested functions This is usefull to wrap C functions headers directly in a D wrapper https://github.com/dlang/dmd/pull/15582
Comment #3 by b2.temp — 2023-09-07T00:29:25Z
*** Issue 17638 has been marked as a duplicate of this issue. ***
Comment #4 by dlang-bot — 2023-09-08T10:14:27Z
dlang/dmd pull request #15582 "fix issue 22682 - `pragma(mangle)` does not work for nested functions" was merged into master: - 440bf2139eff9cc1ee4e22734734e69db3dec0f7 by Basile Burg: fix issue 22682 - `pragma(mangle)` does not work for nested functions This is usefull to declare C functions headers directly in a D wrapper https://github.com/dlang/dmd/pull/15582