1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

zig の使い方

Posted at

zig を使ってみました。

Ubuntu 24.04 にインストール

sudo snap install zig --classic --beta

バージョンの確認

$ zig version
0.13.0

プログラム

hello_world.zig
const std = @import("std");

pub fn main() !void {
    const stdout = std.io.getStdOut().writer();
    try stdout.print("Hello, {s}!\n", .{"world"});
    try stdout.writeAll("Zigg\n");
    try stdout.writeAll("こんにちは\n");
    try stdout.writeAll("今日は良い天気です。\n");
}

コンパイル

Makefile
hello_world: hello_world.zig
	zig build-exe hello_world.zig
clean:
	rm -f hello_world hello_world.o
make
$ make
zig build-exe hello_world.zig

実行

$ ./hello_world 
Hello, world!
Zigg
こんにちは
今日は良い天気です。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?