Bug 10034 – wWinMain and wmain fail to link

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
tools
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2013-05-05T13:44:50Z
Last change time
2021-01-09T21:42:56Z
Assigned to
No Owner
Creator
Diggory

Comments

Comment #0 by diggsey — 2013-05-05T13:44:50Z
Fairly self explanatory, unicode versions of WinMain and main cause a bunch of undefined symbol errors such as: Error 42: Symbol Undefined _D15TypeInfo_Struct6__vtblZ Followed by the message: OPTLINK : Warning 134: No Start Address
Comment #1 by andrej.mitrovich — 2013-05-05T13:55:40Z
Unicode version, what do you mean? AFAIK there's only one possible win main function called WinMain.
Comment #2 by diggsey — 2013-05-05T14:12:24Z
Windows also supports "wmain" and "wWinMain" which are wide character versions of "main" and "WinMain".
Comment #3 by simen.kjaras — 2013-05-05T15:33:02Z
Windows supports neither WinMain nor wWinMain. Windows supports a starting address. MSVC, on the other hand, supports both WinMain and wWinMain. According to documentation, WinMain is the official entry point, and wWinMain is magical, in that it creates a thunk that calls GetCommandLineW and passes that to wWinMain. DMD would thus be free to call its Unicode version of WinMain wWinMain, WinSecondary, foo, or anything else (same goes for the ANSI version). It could even (gasp!) call it WinMain, and create a thunk if the parameters indicate it should be using Unicode. See remarks here: http://msdn.microsoft.com/en-us/library/ms633559.aspx
Comment #4 by pro.mathias.lang — 2021-01-09T21:42:56Z
[wmain is a Microsoft-specific extension](https://docs.microsoft.com/en-us/cpp/c-language/using-wmain?view=msvc-160), and D does not recognize all extensions that MSVC recognize. There's a bit of documentation about it here: https://dlang.org/spec/function.html#betterc-main As explained, it is implementation specific, so this looks like an invalid issue.