D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15496 - Documentation about special/'__' symbols
Summary: Documentation about special/'__' symbols
Status: RESOLVED MOVED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-02 01:25 UTC by Manu
Modified: 2022-10-28 09:03 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Manu 2016-01-02 01:25:42 UTC
DMD emit's a lot of special/magic symbols.

In my current case, I'm piles of link errors like:

error LNK2001: unresolved external symbol _D5libep6string12SharedString14__aggrPostblitMFNbNiZv
error LNK2001: unresolved external symbol _D5libep6string12SharedString11__fieldDtorMFNbNiZv
error LNK2001: unresolved external symbol _D5libep6string12SharedString15__fieldPostblitMFNbNiZv


I don't know why, and I have no idea what those functions are supposed to do, or what actual functions those special names represent? Are they all compiler generated, or are they something that I'm supposed to write?

There seems to be a massive suite of '__x' functions; I'd like to see a reference listing all possible such symbols that users may encounter, and explain what they are, and how they are written or generated. This isn't the first time I've wondered about the many '__' functions.

The only reference that seems to exist are various hacks in phobos where there is code that occasionally checks if they exist to determine some sort of traits.

This doc should ideally also include ClassInfo and any other magic symbols that exist.
Comment 1 weaselcat 2016-01-02 08:20:48 UTC
This may be of interest to you:
http://wiki.dlang.org/Runtime_Hooks

AFAIK these aren't well documented. Hopefully they won't be because they're very, very old should be replaced by something better(e.g, AFAIK none of the hooks can even be inlined.)
Bye.
Comment 2 Manu 2016-01-02 22:34:30 UTC
That's interesting. Although it doesn't list the 'normal'/expected ones, like __dtor/__postblit. It only talks about really obscure ones :P
Comment 3 RazvanN 2022-10-28 09:03:09 UTC
The ones that are present in this bug report are listed here: https://dlang.org/spec/struct.html#struct-postblit (point 5)

Probably not all of these symbols are documented, however, internal compiler symbols should not ever appear in user facing error messages. There are multiple bugs regarding this issues, so I'm going to close this one.