Fixed bug 3508 - variably modified ‘SDL_dummy_size’ at file scope in test/testatomic.c
authorSam Lantinga <slouken@libsdl.org>
Tue, 06 Dec 2016 00:40:09 -0800
changeset 10679a458fc3377dc
parent 10678 8b78fe5b4282
child 10680 fe759a74b018
Fixed bug 3508 - variably modified ‘SDL_dummy_size’ at file scope in test/testatomic.c

Ciro Santilli

GCC 6, Ubuntu 16.10, cd test; ./configure; make

/bin/sh config.status Makefile
config.status: creating Makefile
gcc -o loopwave loopwave.c -g -O2 -D_REENTRANT -I/usr/include/SDL2 -DHAVE_OPENGLES2 -DHAVE_OPENGL -DHAVE_SDL_TTF -g -lSDL2_test -lSDL2
gcc -o testatomic testatomic.c -g -O2 -D_REENTRANT -I/usr/include/SDL2 -DHAVE_OPENGLES2 -DHAVE_OPENGL -DHAVE_SDL_TTF -g -lSDL2_test -lSDL2
In file included from /usr/include/SDL2/SDL_main.h:25:0,
from /usr/include/SDL2/SDL.h:32,
from testatomic.c:14:
/usr/include/SDL2/SDL_stdinc.h:261:20: error: variably modified ‘SDL_dummy_size’ at file scope
typedef int SDL_dummy_ ## name[(x) * 2 - 1]
^
testatomic.c:106:1: note: in expansion of macro ‘SDL_COMPILE_TIME_ASSERT’
SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */
^~~~~~~~~~~~~~~~~~~~~~~
Makefile:114: recipe for target 'testatomic' failed
make: *** [testatomic] Error 1

If I remove the line SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */ it works, lazy to figure out the best way to do this.
test/testatomic.c
     1.1 --- a/test/testatomic.c	Mon Dec 05 21:28:27 2016 -0800
     1.2 +++ b/test/testatomic.c	Tue Dec 06 00:40:09 2016 -0800
     1.3 @@ -103,7 +103,10 @@
     1.4  #define NInter (CountTo/CountInc/NThreads)
     1.5  #define Expect (CountTo-NInter*CountInc*NThreads)
     1.6  
     1.7 -SDL_COMPILE_TIME_ASSERT(size, CountTo>0); /* check for rollover */
     1.8 +enum {
     1.9 +   CountTo_GreaterThanZero = CountTo > 0,
    1.10 +};
    1.11 +SDL_COMPILE_TIME_ASSERT(size, CountTo_GreaterThanZero); /* check for rollover */
    1.12  
    1.13  static SDL_atomic_t good = { 42 };
    1.14