D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10213 - Odd __acrtused error with WinMain
Summary: Odd __acrtused error with WinMain
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2013-05-30 04:38 UTC by Andrej Mitrovic
Modified: 2024-12-13 18:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-05-30 04:38:17 UTC
-----
import core.sys.windows.windows;

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
    version(OK)
    {
        try
        {
            return 0;
        }
        catch (Throwable)
        {
            return 0;
        }
    }
    else
    version(OK2)
    {
        import std.stdio;
        return 0;
    }
    else
    version(FAIL)
    {
        return 0;
    }
}
-----

$ dmd -version=OK -L-Subsystem:Windows:4 test.d
> 

$ dmd -version=OK2 -L-Subsystem:Windows:4 test.d
> 

$ dmd -version=FAIL -L-Subsystem:Windows:4 test.d
> OPTLINK (R) for Win32  Release 8.00.12
> Copyright (C) Digital Mars 1989-2010  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> OPTLINK : Warning 23: No Stack
> test.obj(test)
>  Error 42: Symbol Undefined __acrtused
> OPTLINK : Warning 134: No Start Address

The error seems to go away if you either introduce a try/catch or an import into any 'std' module.

Obviously the chances of having no imports and no try/catch in a module implementing WinMain are very low, but the behavior is strange.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:07:17 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

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

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