The following application will produce an access violation on windows, and when compiling with the "windows" subsystem, will not report any error to the user:
const std = @import("std");
const w = std.os.windows;
pub extern "user32" fn MessageBoxA (
hWnd: ?w.HWND,
lpText: [*:0]const u8,
lpCaption: [*:0]const u8,
uType: u32,
) callconv(w.WINAPI) c_int;
pub export fn wWinMainCRTStartup() callconv(w.WINAPI) noreturn {
// comment out the next line to show that the program works and produces a message box
(@intToPtr(fn() void, 1))();
_ = MessageBoxA(null, "Hello", "We are here", 0);
w.kernel32.ExitProcess(0);
}
Here's how to build:
zig build-exe bug.zig --single-threaded --subsystem windows
Note that when the --subsystem windows arguments are removed, it will popup an error window and provide the user a chance to debug the problem. The problem is that when using the "windows" subsystem, process just dies with no information and no error reported to the user.
The following application will produce an access violation on windows, and when compiling with the "windows" subsystem, will not report any error to the user:
Here's how to build:
Note that when the
--subsystem windowsarguments are removed, it will popup an error window and provide the user a chance to debug the problem. The problem is that when using the "windows" subsystem, process just dies with no information and no error reported to the user.