Skip to content

zig c++ fails to compiles windows with wWinMain/wmain when windows.h is imported #9924

@kbsec

Description

@kbsec

Zig Version

0.8

Steps to Reproduce

#include <windows.h>
#include <iostream>

int wmain(int argc, wchar_t** argv) {
    std::wcout << L"Hello world!" << std::endl;
    if(argc == 2){
        std::wcout << argv[1] << std::endl;
    }
    return 0;
}
zig c++ -target x86_64-windows-gnu test.cpp

Expected Behavior

Should compile as it does with clang++

PS C:\Users\User\Documents\zig_cc_exp> clang++ .\zig_test.cpp                                                           PS C:\Users\User\Documents\zig_cc_exp> .\a.exe                                                                          Hello world! 

Actual Behavior

PS C:\Users\User\Documents\zig_cc_exp> zig c++ -target x86_64-windows-gnu .\zig_test.cpp
lld-link: error: undefined symbol: WinMain
>>> referenced by mingw32.lib(crt0_c.obj):(main)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-windowsMicrosoft Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions