SDL_assert: warning C4127

Hello,

I’m compiling SDL2 app with msvc 2012 with /W4 setting.
When using SDL_assert* macros, msvc is complaining:

warning C4127: conditional expression is constant

I’ve solved this by changing the condition, see the attached patch.–
Matej
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_assert.h.diff
Type: application/octet-stream
Size: 630 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130906/dd89a065/attachment.obj

#define bla(x) do { … } while(0);
is a common idiom (which is supposed to be constant), seems stupid of
the compiler to complain about that.
That your compiler gives a warning about while(0) being constant but not
about while(-1 == LINE) being constant (even though it is just as
constant), is inconsistent and likely to “break” with later versions of
the compiler or other compilers.

Cheers,
DanielAm 06.09.2013 21:42, schrieb Matej ?vec:

Hello,

I’m compiling SDL2 app with msvc 2012 with /W4 setting.
When using SDL_assert* macros, msvc is complaining:

warning C4127: conditional expression is constant

I’ve solved this by changing the condition, see the attached patch.

How about some _pragma magic to keep the VS compiler from complaining?

See here:
http://stackoverflow.com/questions/12042433/how-to-disable-c4127-for-do-whilefalseOn 9/6/2013 12:42 PM, Matej ?vec wrote:

Hello,

I’m compiling SDL2 app with msvc 2012 with /W4 setting.
When using SDL_assert* macros, msvc is complaining:

warning C4127: conditional expression is constant

I’ve solved this by changing the condition, see the attached patch.


Matej


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’ve solved this by changing the condition, see the attached patch.

It’s a clever idea. I’ve just put something like this in revision control.

–ryan.