Skip to content

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

@imclaren01

Description

@imclaren01

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)));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions