Skip to content

Instantly share code, notes, and snippets.

@zacharycarter
Created December 13, 2018 02:53
Show Gist options
  • Save zacharycarter/b7bb8ad90306e69399fc0bd97993f3fc to your computer and use it in GitHub Desktop.
Save zacharycarter/b7bb8ad90306e69399fc0bd97993f3fc to your computer and use it in GitHub Desktop.
const std = @import("std");
const warn = std.debug.warn;
const c = @cImport({
@cInclude("SDL2/SDL.h");
});
const ZealInitializationError = error {
SDLInitializationError,
};
fn init() !void {
// if (c.SDL_Init(c.SDL_INIT_VIDEO | c.SDL_INIT_AUDIO) != 0) {
// c.SDL_Log(c"Unable to initialize SDL: %s", c.SDL_GetError());
// return error.SDLInitializationError;
// }
return error.SDLInitializationError;
}
pub fn main() !void {
errdefer {
warn("encountered an error!\n");
}
init() catch |err| {
// this causes runaway allocation in the compiler!
// https://github.com/ziglang/zig/issues/1753
// std.debug.warn("Platform.init failed: {}.\n", err);
warn("Platform init failed.\n");
return error.DeferError;
};
}
➜ zeal zig build run
Platform init failed.
encountered an error!
error: DeferError
integer overflow
/usr/local/lib/zig/std/mem.zig:706:16: 0x10ddc008d in _join.38 (zeal.o)
if (buf[buf_index - 1] != sep) {
^
/usr/local/lib/zig/std/os/path.zig:51:5: 0x10ddbfd05 in _joinPosix (zeal.o)
return mem.join(allocator, sep_posix, paths);
^
/usr/local/lib/zig/std/os/path.zig:42:9: 0x10ddbfc59 in _join (zeal.o)
return joinPosix(allocator, paths);
^
/usr/local/lib/zig/std/debug/index.zig:1334:31: 0x10ddbafe3 in _LineNumberProgram_checkLineMatch (zeal.o)
const file_name = try os.path.join(self.file_entries.allocator, dir_name, file_entry.file_name);
^
/usr/local/lib/zig/std/debug/index.zig:1679:17: 0x10ddb88a9 in _getLineNumberInfoMacOs (zeal.o)
if (try prog.checkLineMatch()) |info| return info;
^
/usr/local/lib/zig/std/debug/index.zig:594:5: 0x10ddb5d1b in _printSourceAtAddressMacOs (zeal.o)
if (getLineNumberInfoMacOs(di, symbol.*, adjusted_addr)) |line_info| {
^
/usr/local/lib/zig/std/debug/index.zig:266:30: 0x10ddb5a48 in _printSourceAtAddress (zeal.o)
builtin.Os.macosx => return printSourceAtAddressMacOs(debug_info, out_stream, address, tty_color),
^
/usr/local/lib/zig/std/debug/index.zig:197:33: 0x10dda9642 in _writeStackTrace (zeal.o)
try printSourceAtAddress(debug_info, out_stream, return_address, tty_color);
^
/usr/local/lib/zig/std/debug/index.zig:102:20: 0x10dda8816 in _dumpStackTrace (zeal.o)
writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, wantTtyColor()) catch |err| {
^
/usr/local/lib/zig/std/special/bootstrap.zig:115:21: 0x10ddc95fa in _main (zeal.o)
if (@errorReturnTrace()) |trace| {
^
???:?:?: 0x7fff7f5a1015 in ??? (???)
The following command terminated unexpectedly:
cd /Users/zachcarter/projects/zeal && zig-cache/zeal
Build failed. The following command failed:
/Users/zachcarter/Library/Application Support/zig/stage1/artifact/dWcQxNfuxEJ_GxOARHqGQw8hh5U81po_NMiLj2xWAYH7seecad1l3hv24m_bL-Nb/build /usr/local/bin/zig /Users/zachcarter/projects/zeal /Users/zachcarter/projects/zeal/zig-cache run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment