iOS: Fixed compiling demos on C89 compilers.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 01 Apr 2016 21:14:49 +0200
changeset 101384a8b649fee5b
parent 10137 406f82002892
child 10139 bb54e1e47110
iOS: Fixed compiling demos on C89 compilers.
Xcode-iOS/Demos/src/accelerometer.c
Xcode-iOS/Demos/src/happy.c
Xcode-iOS/Demos/src/mixer.c
Xcode-iOS/Demos/src/touch.c
     1.1 --- a/Xcode-iOS/Demos/src/accelerometer.c	Fri Apr 01 21:13:58 2016 +0200
     1.2 +++ b/Xcode-iOS/Demos/src/accelerometer.c	Fri Apr 01 21:14:49 2016 +0200
     1.3 @@ -34,6 +34,7 @@
     1.4  render(SDL_Renderer *renderer, int w, int h)
     1.5  {
     1.6  
     1.7 +    float speed;
     1.8  
     1.9      /* get joystick (accelerometer) axis values and normalize them */
    1.10      float ax = SDL_JoystickGetAxis(accelerometer, 0);
    1.11 @@ -58,7 +59,7 @@
    1.12          ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
    1.13          MILLESECONDS_PER_FRAME;
    1.14  
    1.15 -    float speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
    1.16 +    speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
    1.17  
    1.18      if (speed > 0) {
    1.19          /* compensate for friction */
    1.20 @@ -207,8 +208,8 @@
    1.21      done = 0;
    1.22      /* enter main loop */
    1.23      while (!done) {
    1.24 +        SDL_Event event;
    1.25          startFrame = SDL_GetTicks();
    1.26 -        SDL_Event event;
    1.27          while (SDL_PollEvent(&event)) {
    1.28              if (event.type == SDL_QUIT) {
    1.29                  done = 1;
     2.1 --- a/Xcode-iOS/Demos/src/happy.c	Fri Apr 01 21:13:58 2016 +0200
     2.2 +++ b/Xcode-iOS/Demos/src/happy.c	Fri Apr 01 21:14:49 2016 +0200
     2.3 @@ -147,8 +147,8 @@
     2.4      /* main loop */
     2.5      done = 0;
     2.6      while (!done) {
     2.7 +        SDL_Event event;
     2.8          startFrame = SDL_GetTicks();
     2.9 -        SDL_Event event;
    2.10          while (SDL_PollEvent(&event)) {
    2.11              if (event.type == SDL_QUIT) {
    2.12                  done = 1;
     3.1 --- a/Xcode-iOS/Demos/src/mixer.c	Fri Apr 01 21:13:58 2016 +0200
     3.2 +++ b/Xcode-iOS/Demos/src/mixer.c	Fri Apr 01 21:14:49 2016 +0200
     3.3 @@ -278,6 +278,7 @@
     3.4      Uint32 startFrame;          /* holds when frame started processing */
     3.5      Uint32 endFrame;            /* holds when frame ended processing */
     3.6      Uint32 delay;               /* calculated delay, how long should we wait before next frame? */
     3.7 +    int i;
     3.8  
     3.9      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
    3.10          fatalError("could not initialize SDL");
    3.11 @@ -342,7 +343,6 @@
    3.12      }
    3.13  
    3.14      /* cleanup code, let's free up those sound buffers */
    3.15 -    int i;
    3.16      for (i = 0; i < NUM_DRUMS; i++) {
    3.17          SDL_free(drums[i].buffer);
    3.18      }
     4.1 --- a/Xcode-iOS/Demos/src/touch.c	Fri Apr 01 21:13:58 2016 +0200
     4.2 +++ b/Xcode-iOS/Demos/src/touch.c	Fri Apr 01 21:14:49 2016 +0200
     4.3 @@ -26,15 +26,17 @@
     4.4      float dx_prime = dx / iterations;   /* x-shift per iteration */
     4.5      float dy_prime = dy / iterations;   /* y-shift per iteration */
     4.6      SDL_Rect dstRect;           /* rect to draw brush sprite into */
     4.7 +    float x;
     4.8 +    float y;
     4.9 +    int i;
    4.10  
    4.11      dstRect.w = BRUSH_SIZE;
    4.12      dstRect.h = BRUSH_SIZE;
    4.13  
    4.14      /* setup x and y for the location of the first sprite */
    4.15 -    float x = startx - BRUSH_SIZE / 2.0f;
    4.16 -    float y = starty - BRUSH_SIZE / 2.0f;
    4.17 +    x = startx - BRUSH_SIZE / 2.0f;
    4.18 +    y = starty - BRUSH_SIZE / 2.0f;
    4.19  
    4.20 -    int i;
    4.21      /* draw a series of blots to form the line */
    4.22      for (i = 0; i < iterations; i++) {
    4.23          dstRect.x = x;