D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10034 - wWinMain and wmain fail to link
Summary: wWinMain and wmain fail to link
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: tools (show other issues)
Version: D2
Hardware: All Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-05 13:44 UTC by Diggory
Modified: 2021-01-09 21:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Diggory 2013-05-05 13:44:50 UTC
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 Andrej Mitrovic 2013-05-05 13:55:40 UTC
Unicode version, what do you mean? AFAIK there's only one possible win main function called WinMain.
Comment 2 Diggory 2013-05-05 14:12:24 UTC
Windows also supports "wmain" and "wWinMain" which are wide character versions of "main" and "WinMain".
Comment 3 Simen Kjaeraas 2013-05-05 15:33:02 UTC
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 Mathias LANG 2021-01-09 21:42:56 UTC
[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.