diff --git a/lib/std/start.zig b/lib/std/start.zig index bf6f61f25f..e6c21ba9b8 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -21,7 +21,7 @@ comptime { @export(main, .{ .name = "main", .linkage = .Weak }); } } else if (builtin.os == .windows) { - if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) { + if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and !@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup")) { @export(WinMainCRTStartup, .{ .name = "WinMainCRTStartup" }); } } else if (builtin.os == .uefi) { diff --git a/src/all_types.hpp b/src/all_types.hpp index 651ea807ad..b7cb7e0b5a 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -2175,7 +2175,9 @@ struct CodeGen { bool is_big_endian; bool have_c_main; bool have_winmain; + bool have_wwinmain; bool have_winmain_crt_startup; + bool have_wwinmain_crt_startup; bool have_dllmain_crt_startup; bool have_err_ret_tracing; bool link_eh_frame_hdr; diff --git a/src/analyze.cpp b/src/analyze.cpp index c15b6b3d57..94c24a391e 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3419,8 +3419,12 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, const char *symbol_name, G } else if (cc == CallingConventionStdcall && g->zig_target->os == OsWindows) { if (strcmp(symbol_name, "WinMain") == 0) { g->have_winmain = true; + } else if (strcmp(symbol_name, "wWinMain") == 0) { + g->have_wwinmain = true; } else if (strcmp(symbol_name, "WinMainCRTStartup") == 0) { g->have_winmain_crt_startup = true; + } else if (strcmp(symbol_name, "wWinMainCRTStartup") == 0) { + g->have_wwinmain_crt_startup = true; } else if (strcmp(symbol_name, "DllMainCRTStartup") == 0) { g->have_dllmain_crt_startup = true; } diff --git a/src/codegen.cpp b/src/codegen.cpp index 03417f01e5..431e20ddd3 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8340,9 +8340,9 @@ TargetSubsystem detect_subsystem(CodeGen *g) { if (g->zig_target->os == OsWindows) { if (g->have_dllmain_crt_startup || (g->out_type == OutTypeLib && g->is_dynamic)) return TargetSubsystemAuto; - if (g->have_c_main || g->is_test_build || g->have_winmain_crt_startup) + if (g->have_c_main || g->is_test_build || g->have_winmain_crt_startup || g->have_wwinmain_crt_startup) return TargetSubsystemConsole; - if (g->have_winmain) + if (g->have_winmain || g->have_wwinmain) return TargetSubsystemWindows; } else if (g->zig_target->os == OsUefi) { return TargetSubsystemEfiApplication; diff --git a/src/link.cpp b/src/link.cpp index de09e2df6b..e3c765475c 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -2205,6 +2205,10 @@ static void add_win_link_args(LinkJob *lj, bool is_library, bool *have_windows_d if (!is_library) { if (lj->codegen->have_winmain) { lj->args.append("-ENTRY:WinMain"); + } else if (lj->codegen->have_wwinmain) { + lj->args.append("-ENTRY:wWinMain"); + } else if (lj->codegen->have_wwinmain_crt_startup) { + lj->args.append("-ENTRY:wWinMainCRTStartup"); } else { lj->args.append("-ENTRY:WinMainCRTStartup"); }