Using Zig structures in C code

I’m looking for some examples (docs?) about using structures defined in Zig in C code. In particular: having defined a structure in Zig:

  • how can it be passed to C function?
  • how can it be handled in this C function?

Returning such a structure from C function can be handled by returning the passed structure, so it shouldn’t be a problem, I suppose.

I found this a little unclear in the docs so I switched it around: I declare C structs in C code for anything that needs to be accessed in C functions. Then I import those into Zig and fill in there. I use “translate-c” for converting the .h interface files into Zig although @cImport is supposed to work for that too.

Thx for that suggestion. Should work for situations, when Zig structures don’t need to be accessed in C code.