Thread overview
[Issue 22839] Add equivalent of C 'static' for symbols
Mar 05, 2022
Walter Bright
Mar 05, 2022
Dennis
Mar 14, 2022
Walter Bright
Dec 17, 2022
Iain Buclaw
March 05, 2022
https://issues.dlang.org/show_bug.cgi?id=22839

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
The reason for D's behavior is that when doing metaprogramming, lots of symbols get generated, including private ones. When doing this across multiple files, the generated symbols are often identical, so D puts them in COMDAT sections and the linker merges them so only one appears in the executable.

With your suggestion, the symbols would not be merged, but would be duplicated and consuming executable file size.

This would be a significant change in behavior.

Because of this you suggest marking them differently so the names won't even appear in the object file, and so the linker never attempts to merge them.

This hasn't come up before, so I'd like to see a compelling use case to make a language change?

--
March 05, 2022
https://issues.dlang.org/show_bug.cgi?id=22839

--- Comment #2 from Dennis <dkorpel@live.nl> ---
(In reply to Walter Bright from comment #1)
> This would be a significant change in behavior.

I don't want to change templates or 'normal' extern(D) functions, it's only for niche -betterC purposes.

> This hasn't come up before, so I'd like to see a compelling use case to make a language change?

The use case is: I have a C to D translator, and it doesn't know what to do with `static` declarations. It translates to `private`, but that still results in symbol clashes sometimes (like a library defining a static function `terminate`, which was also defined in a Windows DLL IIRC).

It's not supposed to be a big language change, it could even be a compiler
extension similar to LDC's `pragma(LDC_no_moduleinfo)` and
`pragma(LDC_no_typeinfo)`
(https://wiki.dlang.org/LDC-specific_language_changes), though I'd like all
compilers to use the same syntax for it of course.

--
March 14, 2022
https://issues.dlang.org/show_bug.cgi?id=22839

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22839

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=22839

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/20063

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--