zglfw
zglfw copied to clipboard
Fix for zig master
Currently zglfw doesn't compile on zig master because enums do not support extern
anymore and unused variables are compile errors.
Okay so I've just realized there are some repeat enum
values which prevents compilation, if anyone has suggestions on what to do I'll be happy to implement it to this PR.
Edit: From my inquires in on the zig discord it seems we'll have to remove the duplicate enum
values. Another option (that is now used by translate-c) is to change the extern enums with duplicates to a struct
with public constants in it.
Looks like the new way of translating C enums is to Zig is to create constant c_int
's. (reference: https://github.com/ziglang/zig/issues/2115#issuecomment-827968279)
My opinion is to do it like this:
pub const Key = c_int;
pub const Unknown: Key = -1;
pub const Space: Key = 32;
pub const Apostrophe: Key = 39;
// ...
pub const Menu: Key = 348;
pub const Last: Key = Menu;
and functions that currently use the Key
enum would still look like:
pub fn getKey(window: ?*Window, key: Key) KeyState {
// ...
}
just without the @intToEnum
and @enumToInt
stuff.
For consistency, all enums should be converted to these c_int
constants.
@AlexJMohr Suggestion taken, pushed to update to Zig master