mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 08:02:32 +00:00
Add wWinMain and wWinMainCRTStartup to fix #4376
This commit is contained in:
parent
0e7461d4a3
commit
b55bc5eb26
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user