| ... | @@ -20,6 +20,33 @@ pub const shell32 = @import("windows/shell32.zig"); | ... | @@ -20,6 +20,33 @@ pub const shell32 = @import("windows/shell32.zig"); |
| 20 | | 20 | |
| 21 | pub usingnamespace @import("windows/bits.zig"); | 21 | pub usingnamespace @import("windows/bits.zig"); |
| 22 | | 22 | |
| | 23 | /// `builtin` is missing `subsystem` when the subsystem is automatically detected, |
| | 24 | /// so Zig standard library has the subsystem detection logic here. This should generally be |
| | 25 | /// used rather than `builtin.subsystem`. |
| | 26 | /// On non-windows targets, this is `null`. |
| | 27 | pub const subsystem: ?builtin.SubSystem = blk: { |
| | 28 | if (@hasDecl(builtin, "subsystem")) break :blk builtin.subsystem; |
| | 29 | switch (builtin.os) { |
| | 30 | .windows => { |
| | 31 | if (builtin.is_test) { |
| | 32 | break :blk builtin.SubSystem.Console; |
| | 33 | } |
| | 34 | const root = @import("root"); |
| | 35 | if (@hasDecl(root, "WinMain") or |
| | 36 | @hasDecl(root, "wWinMain") or |
| | 37 | @hasDecl(root, "WinMainCRTStartup") or |
| | 38 | @hasDecl(root, "wWinMainCRTStartup")) |
| | 39 | { |
| | 40 | break :blk builtin.SubSystem.Windows; |
| | 41 | } else { |
| | 42 | break :blk builtin.SubSystem.Console; |
| | 43 | } |
| | 44 | }, |
| | 45 | .uefi => break :blk builtin.SubSystem.EfiApplication, |
| | 46 | else => break :blk null, |
| | 47 | } |
| | 48 | }; |
| | 49 | |
| 23 | pub const CreateFileError = error{ | 50 | pub const CreateFileError = error{ |
| 24 | SharingViolation, | 51 | SharingViolation, |
| 25 | PathAlreadyExists, | 52 | PathAlreadyExists, |