News for hackers. Stuff that matters.
Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by kbolino on Tuesday July 30, 2024 @11:41AM (#41110259)
@cImport works without build.zig and even with build.zig requires no special configuration (ignoring linking).

As it is currently described, @import of C will require build.zig and specific configuration therein.

Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by jeltz on Tuesday July 30, 2024 @12:08PM (#41110656)
And form my experience from Rust that is much less ergonomic. Maybe Zig will do it better than Rust but who knows?
Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by samatman on Tuesday July 30, 2024 @12:09PM (#41110676)
build.zig is on its way to being essential.

I consider that an appropriate development. Binaries need to be built, this should be integrated with the rest of the system in any modern language.

It's not incompatible with using something like CMake or Ninja either, it just puts certain responsibilities inside of build.zig. Where they belong.

Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by throwawaymaths on Tuesday July 30, 2024 @12:26PM (#41110936)
I don't think that's the case. In general you can set up @import modules from the command line, and I'm not 100% sure but I think build.zig generally just templates a command line call anyways.
Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by kbolino on Tuesday July 30, 2024 @12:48PM (#41111251)
I don't think this DSL is finalized yet, but you can see on a linked issue what the build.zig to support @import of C looks like on nightly:

    const translate_c = b.addTranslateC(.{
        .root_source_file = b.path("src/c.h"),
        .target = target,
        .optimize = optimize,
    });
    exe.root_module.addImport("c", translate_c.createModule());
https://github.com/ziglang/zig/issues/20648
Re:C Macro Reflection in Zig – Zig Has Better C Interop Than... by mk12 on Tuesday July 30, 2024 @05:33PM (#41114359)
It won't require build.zig, you'll just have to run zig translate-c on the C file. Andrew's comment here[1] says that @cImport is basically @import + the compiler implicitly running translate-c for you. There was some discussion of removing the translate-c subcommand as well (which would force you to use build.zig), but I don't think it's been decided to do that.

[1] https://github.com/ziglang/zig/issues/20630#issuecomment-225...