pub const c = @cImport({ @cDefine("SDL_DISABLE_OLD_NAMES", {}); @cDefine("SDL_MAIN_HANDLED", {}); @cInclude("SDL3/SDL.h"); @cInclude("SDL3/SDL_main.h"); }); // https://github.com/castholm/zig-examples/blob/77a829c85b5ddbad673026d504626015db4093ac/opengl-sdl/main.zig#L200-L219 pub inline fn errify(value: anytype) error{sdl_error}!switch (@typeInfo(@TypeOf(value))) { .bool => void, .pointer, .optional => @TypeOf(value.?), .int => |info| switch (info.signedness) { .signed => @TypeOf(@max(0, value)), .unsigned => @TypeOf(value), }, else => @compileError("unerrifiable type: " ++ @typeName(@TypeOf(value))), } { return switch (@typeInfo(@TypeOf(value))) { .bool => if (!value) error.sdl_error, .pointer, .optional => value orelse error.sdl_error, .int => |info| switch (info.signedness) { .signed => if (value >= 0) @max(0, value) else error.sdl_error, .unsigned => if (value != 0) value else error.sdl_error, }, else => comptime unreachable, }; }