digitalmars.D.bugs - [Issue 22839] New: Add equivalent of C 'static' for symbols
- d-bugmail puremagic.com (29/29) Mar 03 2022 https://issues.dlang.org/show_bug.cgi?id=22839
https://issues.dlang.org/show_bug.cgi?id=22839 Issue ID: 22839 Summary: Add equivalent of C 'static' for symbols Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl When translating C code to D, I sometimes come across a static function with a name that could easily clash if it weren't static: ``` static void terminate() {} ``` The closest equivalent D signature would be: ``` extern(C) private void terminate() {} ``` However, even with `private` the compiler intentionally emits a global `terminate` symbol to the object file (see Issue 7083). I could mark it extern(D) so it would get a mangled name that wouldn't clash, but that also changes the ABI. Considering static symbol support was added to dmd for ImportC (issue 22428), it might be worth exposing this to D code as well using something like ` Cstatic` or `pragma(noLinkerSymbol)`. --
Mar 03 2022