Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork25
A Zig package for translating C code into Zig code.
License
ziglang/translate-c
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A Zig package for translating C code into Zig code, intended to replace@cImport andzig translate-c.
Addtranslate-c to yourbuild.zig.zon with this command:
$zig fetch --save git+https://github.com/ziglang/translate-cinfo: resolved to commit 1aa9ec052415feeaa0494190ae35a94849a24399
Then, within yourbuild.zig, write something like this:
// An abstraction to make using translate-c as simple as possible.constTranslator=@import("translate_c").Translator;// You *can* pass `target` and/or `optimize` in the options struct here, but it's typically// not necessary. You usually want to build for the host target, which is the default.consttranslate_c=b.dependency("translate_c", .{});constt:Translator= .init(translate_c, .{ .c_source_file=b.path("to_translate.h"), .target=target, .optimize=optimize,});// If you want, you can now call methods on `Translator` to add include paths (etc).// Depend on the translated C code as a Zig module.some_module.addImport("translated",t.mod);// ...or, if you want to, just use the output file directly.consttranslated_to_zig:LazyPath=t.output_file;
For a more complete usage, take a look at theExamples.
This repository contains a few examples in theexamples/ directory. You can test that all of the exampleswork by runningzig build all in that directory.
Within a specific example's directory, runzig build test to test that example. Most also have a stepcalledrun or similar which you can use to run the compiled program without hiding stdout.
About
A Zig package for translating C code into Zig code.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors14
Uh oh!
There was an error while loading.Please reload this page.