Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

signedness

Signedness of type when translated to Zig. Different from QualType.signedness() for char and enums. Returns null for non-int types.

Translator.signedness
fn signedness(t: *Translator, qt: QualType) ?std.builtin.Signedness

File

lib/compiler/translate-c/Translator.zig:1618

Code

fn signedness(t: *Translator, qt: QualType) ?std.builtin.Signedness {
    return loop: switch (qt.base(t.comp).type) {
        .bool => .unsigned,
        .bit_int => |bit_int| bit_int.signedness,
        .int => |int_ty| switch (int_ty) {
            .char => .unsigned, // Always translated as u8
            .schar, .short, .int, .long, .long_long, .int128 => .signed,
            .uchar, .ushort, .uint, .ulong, .ulong_long, .uint128 => .unsigned,
        },
        .@"enum" => |enum_ty| {
            const tag_qt = enum_ty.tag orelse return .signed;
            continue :loop tag_qt.base(t.comp).type;
        },
        else => return null,
    };
}