From 5006226e945fc645e6d9b21252c9eee53cc191cc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 23 Sep 2018 12:22:37 +0200 Subject: Fix various things, add generated zig header files to global include Fix compile_commands.json missing build steps. Fix c includes -> zig includes flags. Fix crash when running sibs new/init without defining lang. Add generated zig header files to global include so they can be used from c/c++. Add zig and zig/c (using zig and c in the same project) examples. --- examples/hello_world_c_zig/src/foo.zig | 8 ++++++++ examples/hello_world_c_zig/src/main.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 examples/hello_world_c_zig/src/foo.zig create mode 100644 examples/hello_world_c_zig/src/main.c (limited to 'examples/hello_world_c_zig/src') diff --git a/examples/hello_world_c_zig/src/foo.zig b/examples/hello_world_c_zig/src/foo.zig new file mode 100644 index 0000000..464eadd --- /dev/null +++ b/examples/hello_world_c_zig/src/foo.zig @@ -0,0 +1,8 @@ +const warn = @import("std").debug.warn; + +extern fn baz() void; + +export fn foo() void { + warn("zig called from c!\n"); + baz(); +} diff --git a/examples/hello_world_c_zig/src/main.c b/examples/hello_world_c_zig/src/main.c new file mode 100644 index 0000000..aeaeae4 --- /dev/null +++ b/examples/hello_world_c_zig/src/main.c @@ -0,0 +1,14 @@ +#include +#include + +void baz() +{ + printf("c called from zig!\n"); +} + +int main(int argc, char **argv) +{ + printf("inside c\n"); + foo(); + return 0; +} -- cgit v1.2.3