Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's a bit more than your typical "interop via C". With a "sized opaque" type you actually can stack allocate C++ values in Zig (and vice versa stack allocate Zig values in C++), i.e.

fn stackExample() void {

    var some_cpp_type: c.SomeCppType = undefined;
    c.some_cpp_type_ctor(&some_cpp_type);
    defer c.some_cpp_type_dtor(&some_cpp_type);

    // ...

}


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: