Zig: FFI(C interop)
hhstore opened this issue · 6 comments
hhstore commented
Zig FFI 教程:
- Zig 和 C 有非常良好的互操作性.
- Zig 深入了解
- ⭐⭐⭐⭐
教程:
无需 FFI, 直接导入 C 的能力:
- https://ziglang.org/learn/overview/#integration-with-c-libraries-without-ffibindings
- https://ziglang.org/documentation/master/#cImport
Zig 作为 C 编译器使用:
导出 C lib:
For WebAssembly:
我写的 c 调用 zig 示例:
hhstore commented
github search:
keywords:
- https://github.com/search?l=Zig&q=cInclude&type=Code
- https://github.com/search?l=zig&p=2&q=%40cImport%28&type=Code
@cImport(
@cInclude(
ffi cases:
- https://github.com/jdmichaud/zig-misc/blob/3bb7dfa1eb21175d89742f434d07b01c570b0589/protocol/src/server.zig#L8
- https://github.com/nsmryan/zig_ctest/blob/5b1572915f1da0cd3633b049b88c0c7a2f0127e9/main.zig#L4
- https://github.com/dimenus/Breakout/blob/3e22c5f82e/src/cimport.zig#L2
- https://github.com/mtha790/Raylib-zig-examples/blob/main/main.zig#L3
热门 c binding 项目:
libc:
lib 示例:
- https://github.com/leecannon/zig-libgit2
- https://github.com/marijnfs/zig-p2p
- https://github.com/ziglibs
- https://github.com/ziglibs/zig-lv2
- https://github.com/MoAlyousef/zfltk
- https://github.com/Not-Nik/raylib-zig
应用示例:
-
https://github.com/kevinw/zig-wasm-game
- wasm 俄罗斯方块游戏
- ⭐⭐⭐⭐⭐
-
https://github.com/Murgalha/sorno/blob/main/src/c.zig#L2
- sqlite 的 CRUD 写法: https://github.com/Murgalha/sorno/blob/main/src/dblogic.zig#L155
grpc 示例:
hhstore commented
hhstore commented
zig + c 教程:
hhstore commented
zig + iOS/MacOS:
搜索:
iOS:
MacOS:
zig + Android:
hhstore commented