Skip to content

root source file has no member called 'main' when WinMain is defined. #3712

Closed
@JesseRMeyer

Description

@JesseRMeyer

On Zig 0.5.0+a11da3773.

zig build-exe ../src/test.zig --subsystem windows
C:\dev\Zig\lib\zig\std\special\start.zig:227:35: error: root source file has no member called 'main'

usingnamespace @import("std").os.windows;

extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;

export stdcallcc fn WinMain(hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?LPWSTR, nShowCmd: INT) INT {
    _ = MessageBoxA(null, c"hello", c"world", 0);

    return 0;
}

Interestingly, the error is only prompted if stdcallcc is not provided, but it's required otherwise the parameters are not accessible to the function as the calling convention is not observed.

If main() is defined then WinMain() is never called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions