iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐥

Compiling C Programs with Zig

に公開

Prepare some sample C source code.

hello.c
#include <stdio.h>

int main() {
   printf("Hello, World!\n");
   return 0;
}

Let's try running it in the terminal.

zig run -l c hello.c

Alternatively, you can also write it as follows:

zig run --library c hello.c

If you need an executable file, it is as follows:

zig cc hello.c -o hello

You can check the version number of the C compiler with --version:

zig cc --version
clang version 16.0.6 (https://github.com/ziglang/zig-bootstrap 1dda86241204c4649f668d46b6a37feed707c7b4)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/bin

Discussion