Closed jiacai2050 closed 2 years ago
Since both c.SQLITE_VERSION_NUMBER and 3025000 are number literals, LLVM may also eliminate the if condition even without comptime ...
Hi,
thanks for the suggestion. Sorry I haven't had time to look into this yet.
Something like you're suggesting would work I think but I actually want to test this with old SQLite versions.
So, I did some test which resulted in #93.
I forgot that with const
values we don't need to add comptime
so the TODO is obsolete: it's already doing comptime checks.
I don't think your suggested sqliteVersionLargeThan
function is that useful as is.
However a function like
fn sqliteVersionLargerThan(major: u8, minor: u8, patch: u8) bool
would be nice.
Here is it
fn sqliteVersionLargeThan(major: u8, minor: u8, patch: u8) bool {
return c.SQLITE_VERSION_NUMBER >= @as(u32, major) * 1000000 + @as(u32, minor) * 1000 + @as(u32, patch);
}
Would you like to make a PR for this ?
https://github.com/vrischmann/zig-sqlite/blob/9d011583eaf01be6bdc8bd3b777fd7e3e2bbf572/errors.zig#L132
I notice this comment when randomly read code, I think a possible way to use comptime here:
What do you think?