From ddca24a6fd9a7d23d168b2195932a32b92a18b09 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Sat, 15 Aug 2020 15:23:46 +0200 Subject: Fix expected type error on 32 bit systems fixes #23 --- README.md | 12 ++++++------ build.zig | 3 +++ clap.zig | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2b38281..06d29c5 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ pub fn main() !void { if (args.flag("--help")) debug.warn("--help\n", .{}); if (args.option("--number")) |n| - debug.warn("--number = {}\n", .{ n }); + debug.warn("--number = {}\n", .{n}); for (args.positionals()) |pos| - debug.warn("{}\n", .{ pos }); + debug.warn("{}\n", .{pos}); } ``` @@ -125,9 +125,9 @@ pub fn main() !void { if (args.flag("--help")) debug.warn("--help\n", .{}); if (args.option("--number")) |n| - debug.warn("--number = {}\n", .{ n }); + debug.warn("--number = {}\n", .{n}); for (args.positionals()) |pos| - debug.warn("{}\n", .{ pos }); + debug.warn("{}\n", .{pos}); } ``` @@ -179,12 +179,12 @@ pub fn main() !void { // arg.param will point to the parameter which matched the argument. switch (arg.param.id) { 'h' => debug.warn("Help!\n", .{}), - 'n' => debug.warn("--number = {}\n", .{ arg.value.? }), + 'n' => debug.warn("--number = {}\n", .{arg.value.?}), // arg.value == null, if arg.param.takes_value == false. // Otherwise, arg.value is the value passed with the argument, such as "-a=10" // or "-a 10". - 'f' => debug.warn("{}\n", .{ arg.value.? }), + 'f' => debug.warn("{}\n", .{arg.value.?}), else => unreachable, } } diff --git a/build.zig b/build.zig index ba92f3d..466f5d0 100644 --- a/build.zig +++ b/build.zig @@ -6,6 +6,7 @@ const Builder = std.build.Builder; pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); + const target = b.standardTargetOptions(.{}); const fmt_step = b.addFmt(&[_][]const u8{ "build.zig", @@ -20,6 +21,7 @@ pub fn build(b: *Builder) void { const tests = b.addTest("clap.zig"); tests.setBuildMode(test_mode); + tests.setTarget(target); tests.setNamePrefix(mode_str ++ " "); const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ "."); @@ -39,6 +41,7 @@ pub fn build(b: *Builder) void { const example = b.addExecutable(example_name, "example/" ++ example_name ++ ".zig"); example.addPackagePath("clap", "clap.zig"); example.setBuildMode(mode); + example.setTarget(target); example.install(); example_step.dependOn(&example.step); } diff --git a/clap.zig b/clap.zig index ff423cc..1711af9 100644 --- a/clap.zig +++ b/clap.zig @@ -290,7 +290,7 @@ pub fn helpFull( var counting_stream = io.countingOutStream(io.null_out_stream); try printParam(counting_stream.outStream(), Id, param, Error, context, valueText); if (res < counting_stream.bytes_written) - res = counting_stream.bytes_written; + res = @intCast(usize, counting_stream.bytes_written); } break :blk res; @@ -303,7 +303,7 @@ pub fn helpFull( var counting_stream = io.countingOutStream(stream); try stream.print("\t", .{}); try printParam(counting_stream.outStream(), Id, param, Error, context, valueText); - try stream.writeByteNTimes(' ', max_spacing - counting_stream.bytes_written); + try stream.writeByteNTimes(' ', max_spacing - @intCast(usize, counting_stream.bytes_written)); try stream.print("\t{}\n", .{try helpText(context, param)}); } } -- cgit v1.2.3