Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig.hiword and zig.loword use pre v0.14.0 definition of Type #39

Open
imclaren01 opened this issue Jan 30, 2025 · 1 comment
Open

zig.hiword and zig.loword use pre v0.14.0 definition of Type #39

imclaren01 opened this issue Jan 30, 2025 · 1 comment

Comments

@imclaren01
Copy link

The definitions in zig.zig to replace the HIWORD and LOWORD macros use pre-0.14.0 definition of Type. This causes

win32\zig.zig:288:10: error: no field named 'Int' in enum '@typeInfo(builtin.Type).@"union".tag_type.?'
        .Int => |int| switch (int.signedness) {
        ~^~~

Relevent code in zig.zig:

pub fn loword(value: anytype) u16 {
    switch (@typeInfo(@TypeOf(value))) {
        .Int => |int| switch (int.signedness) {
            .signed => return loword(@as(@Type(.{ .Int = .{ .signedness = .unsigned, .bits = int.bits } }), @bitCast(value))),
            .unsigned => return if (int.bits <= 16) value else @intCast(0xffff & value),
        },
        else => {},
    }
    @compileError("unsupported type " ++ @typeName(@TypeOf(value)));
}
pub fn hiword(value: anytype) u16 {
    switch (@typeInfo(@TypeOf(value))) {
        .Int => |int| switch (int.signedness) {
            .signed => return hiword(@as(@Type(.{ .Int = .{ .signedness = .unsigned, .bits = int.bits } }), @bitCast(value))),
            .unsigned => return @intCast(0xffff & (value >> 16)),
        },
        else => {},
    }
    @compileError("unsupported type " ++ @typeName(@TypeOf(value)));
}
@marler8997
Copy link
Contributor

Just pushed a fix (e8739b3), let me know if you're still having issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants