From 1d10a062e22858d187d053853b9fa82cda1a8cdc Mon Sep 17 00:00:00 2001 From: Chris Boesch Date: Sun, 19 Feb 2023 17:52:16 +0100 Subject: [PATCH] check for dev1650 and some minor polish --- README.md | 6 ++++-- build.zig | 2 +- exercises/026_hello2.zig | 6 +++--- exercises/093_hello_c.zig | 4 ++-- exercises/094_c_math.zig | 1 + patches/patches/093_hello_c.patch | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c34b728..65fae89 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ or a "systems" level language such as C. Each exercise is self-contained and self-explained. However, you're encouraged to also check out these Zig language resources for more detail: +* https://ziglang.org/learn/ * https://ziglearn.org/ * https://ziglang.org/documentation/master/ @@ -41,7 +42,7 @@ Verify the installation and build number of `zig` like so: ```bash $ zig version -0.11.0-dev.1638+xxxxxxxxx +0.11.0-dev.1650+xxxxxxxxx ``` Clone this repository with Git: @@ -81,7 +82,7 @@ about input: ### Version Changes -Version-0.11.0-dev.1638+xxxxxxxxx +Version-0.11.0-dev.1650+xxxxxxxxx * *2023-02-12* zig 0.11.0-dev.1638 - changes in `std.Build` cache_root now returns a directory struct * *2023-02-04* zig 0.11.0-dev.1568 - changes in `std.Build` (combine `std.build` and `std.build.Builder` into `std.Build`) * *2023-01-14* zig 0.11.0-dev.1302 - changes in `@addWithOverflow` (now returns a tuple) and `@typeInfo`; temporary disabled async functionality @@ -166,6 +167,7 @@ Core Language * [ ] Async <--- IN PROGRESS! * [X] Interfaces * [X] Working with C +* [ ] String formating ## Contributing diff --git a/build.zig b/build.zig index 785cceb..bca0bdf 100644 --- a/build.zig +++ b/build.zig @@ -8,7 +8,7 @@ const print = std.debug.print; // When changing this version, be sure to also update README.md in two places: // 1) Getting Started // 2) Version Changes -const needed_version = std.SemanticVersion.parse("0.11.0-dev.1638") catch unreachable; +const needed_version = std.SemanticVersion.parse("0.11.0-dev.1650") catch unreachable; const Exercise = struct { /// main_file must have the format key_name.zig. diff --git a/exercises/026_hello2.zig b/exercises/026_hello2.zig index 384cb55..cd59b86 100644 --- a/exercises/026_hello2.zig +++ b/exercises/026_hello2.zig @@ -7,9 +7,9 @@ const std = @import("std"); // Take note that this main() definition now returns "!void" rather // than just "void". Since there's no specific error type, this means -// that Zig will infer the error type. This is appropriate in the -// case of main(), but can make a function harder (function pointers) -// or even impossible to work with (recursion) in some situations. +// that Zig will infer the error type. This is appropriate in the case +// of main(), but can make a function harder (function pointers) or +// even impossible to work with (recursion) in some situations. // // You can find more information at: // https://ziglang.org/documentation/master/#Inferred-Error-Sets diff --git a/exercises/093_hello_c.zig b/exercises/093_hello_c.zig index 80b1cb7..f5ff831 100644 --- a/exercises/093_hello_c.zig +++ b/exercises/093_hello_c.zig @@ -53,8 +53,8 @@ pub fn main() void { // specify a file descriptor i.e. 2 for error console. // // In this exercise we use 'write' to output 17 chars, - // but something is missing... - const c_res = ???write(2, "Hello C from Zig!", 17); + // but something is still missing... + const c_res = write(2, "Hello C from Zig!", 17); // let's see what the result from C is: std.debug.print(" - C result ist {d} chars written.\n", .{c_res}); diff --git a/exercises/094_c_math.zig b/exercises/094_c_math.zig index a8596b7..b8e65a3 100644 --- a/exercises/094_c_math.zig +++ b/exercises/094_c_math.zig @@ -29,5 +29,6 @@ pub fn main() !void { // Here we call the C function 'fmod' to get our normalized angel. const result = c.fmod(angel, circle); + // We use formatters for the desired precision and to truncate the decimal places std.debug.print("The normalized angle of {d: >3.1} degrees is {d: >3.1} degrees.\n", .{ angel, result }); } diff --git a/patches/patches/093_hello_c.patch b/patches/patches/093_hello_c.patch index df9fbfb..60eeaf0 100644 --- a/patches/patches/093_hello_c.patch +++ b/patches/patches/093_hello_c.patch @@ -1,4 +1,4 @@ 57c57 -< const c_res = ???write(2, "Hello C from Zig!", 17); +< const c_res = write(2, "Hello C from Zig!", 17); --- > const c_res = c.write(2, "Hello C from Zig!", 17);