View sine.zig
const c = @cImport(@cInclude("soundio/soundio.h"));
const io = @import("std").io;
const cstr = @import("std").cstr;
const panic = @import("std").debug.panic;
const math = @import("std").math;
error NoMem;
error InitAudioBackend;
error SystemResources;
error OpeningDevice;
View output
[nix-shell:~/dev/zig/build]$ ./zig build_obj test2.zig
| "sin_result", 0.909297
| "fabs_result", 0.909297
| "fabs_bits", 1063831479
| "scaled_up", 3905402623.090703
| "anded", 3905402623
/home/andy/dev/zig/build/test2.zig:11:5: error: found compile log statement
@compileLog("sin_result", sin_result);
/home/andy/dev/zig/build/test2.zig:12:5: error: found compile log statement

Note this:

call fastcc void @testEnumTagNameBare(%"[]u8"* %0, i2 -2), !dbg !29

We pass i2 -2 which is the unsigned value 2.

After optimizations, the value becomes i64 -2 which is the unsigned value 18446744073709551614.

View test1.ll
define i32 @main(i32, i32) {
%ok = icmp ult i32 %1, 32
br i1 %ok, label %ok_label, label %bad_label
ret i32 0
%a = lshr i32 %0, %1
ret i32 %a
View log.txt
<andrewrk> on freebsd, the default environment is "unknown"
<andrewrk> what are the implications of this?
<andrewrk> is it really not one of gnu gnuabi64 gnueabi gnueabihf gnux32 code16 eabi eabihf android musl musleabi musleabihf msvc itanium cygnus amdopencl coreclr ?
<compnerd> andrewrk: it just means that its not a specific environment, so the compiler can't make assumptions about what may be available
<andrewrk> compnerd, what's an example of something that would be available? what kind of things?
<compnerd> andrewrk: any gnu extensions in libc
<compnerd> andrewrk: or if the architecture is arm, can't assume that the environment conforms to EABI or EHABI
<andrewrk> compnerd, this is for generating libcalls only? does it have anything to do with ABI compatibility?
<compnerd> andrewrk: no, it can deal with ABI as well
<andrewrk> compnerd, how can the ABI be unknown? wouldn't there be *some* entry which corresponds to the ABI that we want to use?
View demo.zig
const assert = @import("std").debug.assert;
/// Compile-time parameters is how Zig implements generics. It is compile-time duck typing and it works mostly the same way that C++ template parameters work. Example:
//fn max(comptime T: type, a: T, b: T) -> T {
// if (a > b) a else b
//fn gimmeTheBiggerFloat(a: f32, b: f32) -> f32 {
// max(f32, a, b)
pub fn isatty(handle: winapi::HANDLE) -> bool {
unsafe {
let handle = kernel32::GetStdHandle(handle);
// check for msys/cygwin
if is_cygwin_pty(handle) {
return true;
let mut out = 0;
View test.zig
const mem = @import("std").mem;
const assert = @import("std").debug.assert;
const AllocState = struct {
some_mem: [100 * 1024]u8,
index: usize,
fn alloc(a: &mem.Allocator, n: usize) -> %[]u8 {
const self = @ptrCast(&AllocState, a.context);
const result = self.some_mem[self.index ... self.index + n];
View output.txt
[nix-shell:~/dev/zig/build]$ ./zig test ../std/os/path.zig --test-filter resolve
Test 1/1 os.path.resolve...OK
[nix-shell:~/dev/zig/build]$ ./zig test ../std/os/path.zig 
/home/andy/dev/zig/std/buffer.zig:105:24: error: container 'Buffer' has no member called 'initFromBuffer'
    var buf2 = %%Buffer.initFromBuffer(&buf);
/home/andy/dev/zig/std/buffer.zig:106:15: error: no member named 'eqlBuffer' in 'Buffer'