aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2023-02-16 11:15:07 +0100
committerChris Boesch <chrboesch@noreply.codeberg.org>2023-02-16 11:15:07 +0100
commit9693860bc0cbb49ac68ad23a8297be6eb1bc2add (patch)
treee8dd8005a683bbd233ecdf68c1a9153a395a4cb2
parent4cf3bd63a22bd2f88c1f04cddac31aa19bc78a9d (diff)
inserted a workaround for mac-os, see https://github.com/ziglang/zig/issues/14657#issuecomment-1432180967
-rw-r--r--exercises/093_hello_c.zig11
-rw-r--r--patches/patches/093_hello_c.patch6
2 files changed, 13 insertions, 4 deletions
diff --git a/exercises/093_hello_c.zig b/exercises/093_hello_c.zig
index ba76a46..d234165 100644
--- a/exercises/093_hello_c.zig
+++ b/exercises/093_hello_c.zig
@@ -49,13 +49,22 @@ const c = @cImport({
pub fn main() void {
+ // Due to a current limitation in the Zig compiler,
+ // we need a small workaround to make this exercise
+ // work on mac-os.
+ const builtin = @import("builtin");
+ const stderr = switch (builtin.target.os.tag) {
+ .macos => 1,
+ else => c.stderr,
+ };
+
// In order to output a text that can be evaluated by the
// Zig Builder, we need to write it to the Error output.
// In Zig we do this with "std.debug.print" and in C we can
// specify the file to write to, i.e. "standard error (stderr)".
//
// Ups, something is wrong...
- const c_res = fprintf(c.stderr, "Hello C from Zig!");
+ const c_res = fprintf(stderr, "Hello C from Zig!");
// let's see what the result from C is:
std.debug.print(" - C result ist {d} chars\n", .{c_res});
diff --git a/patches/patches/093_hello_c.patch b/patches/patches/093_hello_c.patch
index 15e2a44..a0f62c2 100644
--- a/patches/patches/093_hello_c.patch
+++ b/patches/patches/093_hello_c.patch
@@ -1,4 +1,4 @@
-58c58
-< const c_res = fprintf(c.stderr, "Hello C from Zig!");
+63c63
+< const c_res = fprintf(stderr, "Hello C from Zig!");
---
-> const c_res = c.fprintf(c.stderr, "Hello C from Zig!");
+> const c_res = c.fprintf(stderr, "Hello C from Zig!");