Skip to content
Michael Dusan edited this page Jul 21, 2019 · 8 revisions

Where is the documentation for the Zig standard library?

There is no stdlib documentation yet, but it is planned for the next release. For now, the best ways to learn about the standard library are:

  • Browse the stdlib code to see what public functions and types are available.
  • Check out the community and ask questions if you need help. Newcomers are always welcome!

Why does Zig force me to use spaces instead of tabs?

After a very lengthy discussion about tabs and spaces, it was decided that only spaces would be allowed.

The biggest reason to enforce an indentation and line endings is that it eliminates energy spent on debating what the standard should be, since the standard is enforced by the compiler.

The issue of other whitespace characters has been discussed too, and similar decisions were made. Zig aims to offer only one way to do things whenever possible. This makes the cognitive load lower for programmers and keeps the compiler code base simpler and easier to understand.

Note that as of 2019-07-05, when running zig fmt, tabs and carriage returns will be accepted and converted automatically.

How do I make zig fmt skip a range of source lines?

zig fmt will parse comments for special directives.

In this example all code between // zig fmt: off and // zig fmt: on will be excluded from formatting:

// zig fmt: off
const matrix = Matrix{1.0, 0.0, 0.0, 0.0,
                      0.0, 1.0, 0.0, 0.0,
                      0.0, 0.0, 1.0, 0.0,
                      0.0, 0.0, 0.0, 1.0};
// zig fmt: on

Explain this error: Unable to create builtin.zig: access denied

When building or compiling with Zig a build-cache is used. This particular error indicates filesystem security has prevented access to a directory or file used in the global build-cache. Fixing permissions should solve the issue.

note: It is safe to manually remove cache directories when no zig compiler process is active.

As of Zig 0.4.0 the build cache can be found in the following locations unless overridden with command-line options:

TYPE OS DIRECTORY
global linux $HOME/.local/share/zig
macOS $HOME/Library/Application Support/zig
Windows %LOCALAPPDATA%\zig
local all $PWD/zig-cache
You can’t perform that action at this time.