Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using mouse button mask (SDL_BUTTON_LMASK, etc.) leads to compile error #65

Open
ttrei opened this issue May 9, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@ttrei
Copy link
Contributor

ttrei commented May 9, 2022

Minimal example:

const sdl = @import("sdl2");

pub fn main() void {
    _ = sdl.SDL_BUTTON_LMASK;
}

The error:

./deps/sdl/src/binding/sdl.zig:2475:32: error: expected type 'u5', found 'c_int'
    return @as(c_int, 1) << (X - @as(c_int, 1));
                               ^

Tested with zig-0.9.1 and zig-0.10.0-dev.1838+3bfb1616d.

The problem is within SDL_BUTTON() function:
https://github.com/MasterQ32/SDL.zig/blob/bf72bbef8c1c113b2862ff2fab33b1fedbf159f6/src/binding/sdl.zig#L2474-L2476

Experimented with intCast: return @as(c_int, 1) << @intCast(u5, (X - @as(c_int, 1)));
It fixes this issue, but I'm not experienced enough to know if this is the correct solution.

@ikskuh ikskuh added the bug Something isn't working label May 9, 2022
@ttrei
Copy link
Contributor Author

ttrei commented May 9, 2022

Making X comptime also fixes the error:
pub inline fn SDL_BUTTON(comptime X: c_int) c_int {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants