cImport
Zig's @cImport
builtin is
unique in that it takes in an expression, which can only take in
@cInclude
,
@cDefine
, and
@cUndef
. This works
similarly to translate-c, translating C code to Zig under the hood.
@cInclude
takes in a
path string and adds the path to the includes list.
@cDefine
and
@cUndef
define and
undefine things for the import.
These three functions work exactly as you'd expect them to work within C code.
Similar to @import
, this
returns a struct type with declarations. It is typically recommended to only use
one instance of @cImport
in an application to avoid symbol collisions; the types generated within one
cImport will not be equivalent to those generated in another.
cImport is only available when linking libc.