zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2fc2d88fc659f456e21d40a11e1d7bdcfa243f53 (tree)
parent da8d4d922518300a8e041f59cf994f1f83ce1f48
Author: Jonathan Marler <johnnymarler@gmail.com>
Date:   Mon, 24 Jan 2022 00:52:25 -0700

use explicit integer bit widths for windows GUID

The size of a GUID is not platform-dependent, it's always a fixed number of bits.  So I've updated guid to use fixed bit integer types rather than platform-dependent C integer types.

Diffstat:
Mlib/std/os/windows.zig | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig @@ -2733,9 +2733,9 @@ pub const HRESULT = c_long; pub const KNOWNFOLDERID = GUID; pub const GUID = extern struct { - Data1: c_ulong, - Data2: c_ushort, - Data3: c_ushort, + Data1: u32, + Data2: u16, + Data3: u16, Data4: [8]u8, pub fn parse(str: []const u8) GUID { @@ -2744,19 +2744,19 @@ pub const GUID = extern struct { assert(str[index] == '{'); index += 1; - guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index .. index + 8], 16) catch unreachable; + guid.Data1 = std.fmt.parseUnsigned(u32, str[index .. index + 8], 16) catch unreachable; index += 8; assert(str[index] == '-'); index += 1; - guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable; + guid.Data2 = std.fmt.parseUnsigned(u16, str[index .. index + 4], 16) catch unreachable; index += 4; assert(str[index] == '-'); index += 1; - guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable; + guid.Data3 = std.fmt.parseUnsigned(u16, str[index .. index + 4], 16) catch unreachable; index += 4; assert(str[index] == '-');