I get an error at runtime when trying to write some simple code importing the Allegro 5 C library, here's that code:
const std = @import("std");
const al = @cImport({
@cInclude("allegro5/allegro5.h");
});
pub fn main() void {
_ = al.al_init();
const display = al.al_create_display(320, 200);
defer al.al_destroy_display(display);
}
(do we really not have markdown code support for zig? sadge)
Specifically, the code gets called when creating the display. Here's the full error message:
Illegal instruction at address 0x7ff819793e7b
???:?:?: 0x7ff819793e7b in ??? (libdispatch.dylib)
Unwind information for `libdispatch.dylib:0x7ff819793e7b` was not available, trace may be incomplete
???:?:?: 0x65707974687464 in ??? (???)
run allegro-test: error: the following command terminated unexpectedly:
/Users/mak/dev/zig/allegro-test/zig-out/bin/allegro-test
Build Summary: 3/5 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run allegro-test failure
error: the following build command failed with exit code 1:
/Users/mak/dev/zig/allegro-test/zig-cache/o/6f137061620a950d5546c148bfc6d367/build /Users/mak/dev/_SDKs/zig/zig /Users/mak/dev/zig/allegro-test /Users/mak/dev/zig/allegro-test/zig-cache /Users/mak/.cache/zig run
I read that Zig enables UBSan by default, so I tried adding exe.disable_sanitize_c = true to see if that works, but it doesn't. I also tried using the ReleaseFast optimize option, but that didn't work either, instead producing a new error that I can't post due to character limit.