Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
/translate-cPublic archive

A Zig package for translating C code into Zig code.

License

NotificationsYou must be signed in to change notification settings

ziglang/translate-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

209 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Zig package for translating C code into Zig code, intended to replace@cImport andzig translate-c.

Usage

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.

Examples

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

Stars

Watchers

Forks

Sponsor this project

    Contributors14


    [8]ページ先頭

    ©2009-2026 Movatter.jp