Closed paulevans closed 3 years ago
So I guess the language changed how you declare inline?
pub fn setup(desc: Desc) callconv(.Inline) void {
sg_setup(&desc);
}
compiles - it then fails on shutdown.
So this is more of a TODO for 8.0 than a bug!
fwiw zig fmt
will automatically upgrade that particular thing to the new syntax.
Thanks, you are correct. That almost worked. Had to change one extra line in debugtext-print.zig to read "Hello '{s}'!" - adding that s. Here's the diff: https://github.com/floooh/sokol-zig/compare/master...paulevans:zig8.0?expand=1
FWIW I'll try to return to the Zig bindings soon-ish after I've taken care of a couple of pending issues and PRs for the sokol headers. That specific inline
thing can be changed here in the generator-script:
https://github.com/floooh/sokol/blob/master/bindgen/gen_zig.py#L436
However, the underlying C-APIs of the sokol-headers have changed a bit (regarding signed vs unsigned parameters) which would also break the current example code. I'll need to do some type-mapping in the bindings-generator, because in Zig I want to change some function parameters to unsigned where the C-API has signed numbers (reason being that it's "safer" to use unsigned parameters in Zig because of Zigs robust overflow checking, while in C it's easy to accidentally produce an underflow, so for C, using "almost always signed" makes more sense).
I have been looking at patching the generator actually already. Although I didn't realize I needed clang installed to run it. So I have been on-and-off prodding that clang build on my windows machine - been a while since I last did that and on a different machine. Ended up fixing something tiny in fips as well. Just something windows specific to do with windows store installed python. Anything I think is useful enough to share I'll fire off some pull requests. I have been seeing if I could get the sokol-imgui bindings generated for zig. Though thanks for the heads up, sounds like that probably won't work out with recent changes. So were you planning on just having a shim that cast between signed and unsigned in the bindings layer then? I've just started to poke around in zig and I know it can compile c - though not tried that myself yet - just via other people's projects. The idea of the extra bindings is to take better advantage of zig's safety features and make things seem more zig-gy?
On Fri, 19 Feb 2021 at 04:16, Andre Weissflog notifications@github.com wrote:
FWIW I'll try to return to the Zig bindings soon-ish after I've taken care of a couple of pending issues and PRs for the sokol headers. That specific inline thing can be changed here in the generator-script:
https://github.com/floooh/sokol/blob/master/bindgen/gen_zig.py#L436
However, the underlying C-APIs of the sokol-headers have changed a bit (regarding signed vs unsigned parameters) which would also break the current example code. I'll need to do some type-mapping in the bindings-generator, because in Zig I want to change some function parameters to unsigned where the C-API has signed numbers (reason being that it's "safer" to use unsigned parameters in Zig because of Zigs robust overflow checking, while in C it's easy to accidentally produce an underflow, so for C, using "almost always signed" makes more sense).
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/floooh/sokol-zig/issues/7#issuecomment-781978573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFPRSFFMZPCOYBNH45R3JLS7Y26ZANCNFSM4X3NNLBA .
I needed clang...
I found the easiest way to install clang on Windows is scoop install llvm
(also python, cmake, even zig). I haven't tested the code generator on Windows though, mostly used macOS and Linux for this stuff. If clang is in the path it should work on Windows too though.
is to take better advantage of zig's safety features and make things seem more zig-gy
Yep, mostly to make the sokol C-APIs more "zig-gy", but Zig was also an easy first target because it binds really well to C-APIs. The long-term goal is though to support more language bindings with minimal work. Next up is nim support for instance.
I wrote a blog post about this here: https://floooh.github.io/2020/08/23/sokol-bindgen.html
Hello, I saw in the one other issue currently open that you are sticking with zig 7.1 right now... but thought it would be worthwhile giving you a heads up anyway. The line it is complaining about seems okay to me?