{"id":15099759,"url":"https://github.com/thehxdev/c-zig","last_synced_at":"2026-02-15T10:36:19.192Z","repository":{"id":256532495,"uuid":"855457745","full_name":"thehxdev/c-zig","owner":"thehxdev","description":"A simple example of how to use Zig compiler to compile both C and Zig source files into a single executable","archived":false,"fork":false,"pushed_at":"2024-09-11T09:29:46.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T08:41:13.291Z","etag":null,"topics":["c","zig"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thehxdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-10T22:40:05.000Z","updated_at":"2024-09-17T00:19:23.000Z","dependencies_parsed_at":"2024-09-11T13:02:05.577Z","dependency_job_id":"7c41d5ab-c88a-4676-b828-a24f0a5db1d5","html_url":"https://github.com/thehxdev/c-zig","commit_stats":null,"previous_names":["thehxdev/c-zig"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thehxdev/c-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thehxdev%2Fc-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thehxdev%2Fc-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thehxdev%2Fc-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thehxdev%2Fc-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thehxdev","download_url":"https://codeload.github.com/thehxdev/c-zig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thehxdev%2Fc-zig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29475754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T10:25:47.032Z","status":"ssl_error","status_checked_at":"2026-02-15T10:25:01.815Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","zig"],"created_at":"2024-09-25T17:27:31.347Z","updated_at":"2026-02-15T10:36:19.176Z","avatar_url":"https://github.com/thehxdev.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C-Zig\nJust a simple example of how to use Zig compiler to compile `adder.c` and `main.zig` file that includes a C header file called `adder.h`.\nRead the [build.sh](build.sh) file to learn more.\n\n## Build\nJust run the `build.sh` script.\n```bash\n./build.sh\n```\n\n## Why a build script?\nZig is capable of compiling C source code. But the problem is Zig compiler needs to know where to find C headers (aka. Include directories like `/usr/include`).\nIn the command line you can literally do this in project's root directory:\n```bash\nzig build-exe -I. adder.c main.zig\n```\nZig compiler will compile both C and Zig source files into a single executable!\n\nHere, I just included `adder.h` file in `main.zig`. So technically I just need to add the current directory `./` to be searched for header files.\nSo like C compilers we can use `-I` flag to add a directory to be searched for header files by zig compiler (`-I.`).\nThen Zig compiler can find `adder.h`.\n\nIn case you want to use libc (like `stdio.h`) you need to find and add system include directories with `-I` flag.\nThen you have to link the final executable against libc with `-lc` flag passed to zig compiler. So I created `build.sh` as an example for that.\n\nNote that I didn't initialized any zig project with `zig init` command. If you are created a Zig project all of the things above can be declared in the `build.zig` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthehxdev%2Fc-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthehxdev%2Fc-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthehxdev%2Fc-zig/lists"}