Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
1–10 of 60 posts
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#2Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#3Can anyone provide some context? I don't know what GLFW is, and the blog post doesn't really explain. From Googling, I see what it is now, but I don't really have a sense of how important GLFW bindings are. Is this very niche? Or, like is this a major contribution to game development? For that matter, is this mainly going to help Zig game developers, or is this a bit of tooling for everyone, kind of like zig cc?
This helps just Zig game developers for now, it's not a major contribution to game development (though I hope other things I do with Mach engine in the future will be.)
I do think with some minor tweaks this could be used to make bindings for GLFW in other languages easier to install, e.g. by just requiring `zig`, but I haven't done that here.
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#4Can anyone provide some context? I don't know what GLFW is, and the blog post doesn't really explain. From Googling, I see what it is now, but I don't really have a sense of how important GLFW bindings are. Is this very niche? Or, like is this a major contribution to game development? For that matter, is this mainly going to help Zig game developers, or is this a bit of tooling for everyone, kind of like zig cc?
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#5Can anyone provide some context? I don't know what GLFW is, and the blog post doesn't really explain. From Googling, I see what it is now, but I don't really have a sense of how important GLFW bindings are. Is this very niche? Or, like is this a major contribution to game development? For that matter, is this mainly going to help Zig game developers, or is this a bit of tooling for everyone, kind of like zig cc?
glfw is very widely known because it's usually one of the recommended libraries to use when starting out graphics programming. It basically a cross platform library to create a window and initialize an opengl context .. or something like that. (It's been _many_ years since I last used it).
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#6Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#7Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#8The article discusses some undefined behaviour resulting from shifting an unsigned char left by 24 places. Any idea why the compiler wasn't warning about that? It seems like it would be easy to implement that warning in the compiler. I feel that I'm missing something.
> Anybody using GLFW could have enabled UBSan in their C compiler. Anybody could have run into this same crash and debugged it in the last 6 years. But they didn’t. Only because Zig has good defaults, because it places so much emphasis on things being right out of the box, and because there is such an emphasis on having safety checks for undefined behavior - were we able to catch this undefined behavior that went unnoticed in GLFW for the last 6 years.
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#9Earlier quoted context omitted.
glfw is very widely known because it's usually one of the recommended libraries to use when starting out graphics programming. It basically a cross platform library to create a window and initialize an opengl context .. or something like that. (It's been _many_ years since I last used it).
Is it safe to say that SDL is a strict superset of GLFW?
Re: Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnot
#10The article discusses some undefined behaviour resulting from shifting an unsigned char left by 24 places. Any idea why the compiler wasn't warning about that? It seems like it would be easy to implement that warning in the compiler. I feel that I'm missing something.
#include
void foo() {
uint32_t foo = 1;
foo
According to godbolt, the following warning is emitted for gcc: warning: left shift count >= width of type [-Wshift-count-overflow]
And for clang: warning: shift count >= width of type [-Wshift-count-overflow]
https://godbolt.org/z/ffccWexMP