Open N-R-K opened 2 years ago
We didn't really resolve this in #1099. I'm not a big fan of using memset() because it's ugly, but I'm not really a big fan of ZERO_INIT because it introduces the #ifdef. I mean, I understand it's harmless, it's just ugly in its own way.
If we did take this PR, it needs to be STBIW_ZERO_INIT and etc. for each library, so they don't interfere if the user has "ZERO_INIT" in their code with some other meaning. (And simply #undef
ing at the end isn't sufficient, since they could #define it before including us.)
I'm not a big fan of using memset() because it's ugly, but I'm not really a big fan of ZERO_INIT because it introduces the #ifdef. I mean, I understand it's harmless, it's just ugly in its own way.
I agree actually.
If we did take this PR, it needs to be STBIW_ZERO_INIT and etc. for each library, so they don't interfere if the user has "ZERO_INIT" in their code with some other meaning.
That's true. I'll wait until you make up your mind on it before updating the PR then.
NB: I'm fine if this is rejected, only opened it because you agreed to use memset()
which I think is more ugly than the macro.
Updated to using memset(), compiles fine on both gcc and clang without any warnings with -Wall -Wextra -Wmissing-field-initializers
.
There are also several places where such initializer is used:
* stb_ds.h in line [764](https://github.com/nothings/stb/blob/af1a5bc352164740c1cc1354942b1c6b72eacb8a/stb_ds.h#L764) (also, I don't know for what purpose this variable is used here). * stb_image.h in lines [5026](https://github.com/nothings/stb/blob/af1a5bc352164740c1cc1354942b1c6b72eacb8a/stb_image.h#L5026) and [5815](https://github.com/nothings/stb/blob/af1a5bc352164740c1cc1354942b1c6b72eacb8a/stb_image.h#L5815).
Thanks, I updated the list in https://github.com/nothings/stb/pull/1311#issue-1167509162 along with the grep expression to catch {0}
(no spaces between braces and zero) as well.
Closes: https://github.com/nothings/stb/issues/1099
Grep finds a couple more instances of
{ 0 }
being used:Fixing them should be the same as this PR, should I go ahead and update those too?