View test.zig
const std = @import("std");
pub fn main() !void {
const epollfd = blk: {
const rc = std.os.linux.epoll_create1(std.os.linux.EPOLL_CLOEXEC);
const err = std.os.linux.getErrno(rc);
if (err != 0) return error.EpollCreateFailed;
break :blk i32(rc);
defer std.os.close(epollfd);
View windows_h.zig
This file has been truncated, but you can view the full file.
pub const va_list = ?&u8;
pub extern fn __va_start(arg0: ?&(?&u8));
pub const ptrdiff_t = c_longlong;
pub const __vcrt_bool = bool;
pub const wchar_t = c_ushort;
pub extern fn __security_init_cookie();
pub extern fn __security_check_cookie(_StackCookie: usize);
pub extern fn __report_gsfailure(_StackCookie: usize) -> noreturn;
pub extern var __security_cookie: usize;
View map.zig
const std = @import("std");
/// Can return error.OutOfMemory
/// Caller owns the returned memory
fn map(allocator: &std.mem.Allocator, comptime T: type, items: []const T, func: fn(T)->T) -> %[]T {
const new_items = try allocator.alloc(T, items.len);
for (items) |item, i| {
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;