Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.32 KB

readme.md

File metadata and controls

53 lines (34 loc) · 1.32 KB

c call zig:

quickStart:

generate c header: .h

  • ✅ use zig v0.6.0 to generate c header with docker image: zig v0.6.0
  • ✅ generate result: src/mathtest.h
  • zig v0.9+, zig build-lib -fno-stage1 -femit-h src/mathtest.zig, not working properly.
# cd this-dir/; do:
docker run --platform linux/x86_64 -v $PWD:/app euantorano/zig:0.6.0 build-lib src/mathtest.zig -femit-h

# or:
task docker:build

# or cd repo-root/; do:
 task to:c:docker:build
task: [to:c:docker:build] docker run --platform linux/x86_64 -v $PWD:/app euantorano/zig:0.6.0 build-lib src/mathtest.zig -femit-h
Warning: Unable to write cache file '/root/.cache/zig/stage1/exe/p4rsuZZL85fcyluOF06tMxUXMA_oSkmX2uOSW6AO5sheEcde9uIqY5KNylHLQNZ8.txt': unexpected seek failure
task: [to:c:docker:build] cp *.h src/
task: [to:c:docker:build] rm *.h;

# v0.9+, try this, but not working properly!
zig build-lib -fno-stage1 -femit-h src/mathtest.zig

build + run:

# cd this-dir/; do:
zig build run

# or cd this-dir/; do:
task run


# or cd repo-root/; do:
 task to:c:run
task: [to:c:run] zig build run
c call zig >> add() = 1379

enjoy!