make qoi.h build using c89 compilers.#67
make qoi.h build using c89 compilers.#67phoboslab merged 1 commit intophoboslab:masterfrom sezero:c89
Conversation
|
I went ahead and implemented my suggestion of |
|
Rebased to current master. |
|
Rebased (again) + revised. |
also add a QOI_ZEROARR macro, wrapping around memset by default.
|
Rebased |
|
I'm not a fan of having all variable declarations at the top of the functions, but of course not opposed to that if it's required. I'm confused about the actual standards though. I compiled with Fair enough. So we can't use single line comments if we want to conform to c89? Meh... Only(!) when I compile with and The one thing my gcc did not(!) complain about was the So, which standard and/or compiler exactly are we targeting here? Is this just "whatever SDL is compiled with", or is there some more universal guidelines of what exactly is required? |
Those changes are to avoid
... and those
C99 initializers aren't supported by older non-gcc (older MSVC for e.g.,
That's not about c99 or c89 or c11: see the original note: if the compiler
These are suggestions only. You decide what standards you want to |
Makes sense. Thanks for clarifying! Interestingly SDL_image at some point apparently honored the "no
SDL itself seems to allow designated initializers, but only in code that targets linux, QNX, PSP or in Also, thanks for your work and sorry if this came off blunt. I'm very excited to see QOI in SDL! I just wanted to know the motivation for these specific changes. I'll merge this soon. But I guess it would be a good idea for QOI to go full-c89, instead of MSVC's "c89 with benefits", if we're halfway there anyway... |
AFAIK, SDL usually lives OK with single line comments within its own code
Yes, the gcc-only parts are more lenient. (I hadn't noticed designated initializers
Thanks. |
This patch makes qoi.h to build using c89 compilers.
Note: Even with this, my gcc emits the following warnings:
These are qoi_rgba_t index[64] = {0}; and a compiler (e.g. MSVC)
can optimize those to memset(index,0,sizeof(index)) which can be
a problem with users of the header. I suggest that qoi project
expose a QOI_ZERO macro and use it instead of those initializers.
E.g.: