www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Odd behaviour of loop

I've been playing with DerelictSDL, and I'm getting some rather odd 
behaviour on my inner loop.

Basically, when I use a bit flag for the condition on the while loop, 
something keeps setting it to false, but when I change it to an int, it 
works as expected.

Here's the code for the inner loop (there's nothing of any particular 
interest outside there)

//////////////////////////////////////////////////////////////////////////////

int main()
{
     SDL.initEverything();
     Window.show();

     SDL_Event event;
     //bit running = true;
     int running = 1;

     //while(running == true)
     while(running == 1)
     {
         while(SDL_PollEvent(&event))
         {
             switch( event.type )
             {
                 case SDL_QUIT:
                     stdout.writeLine("Event: SDL_QUIT");
                     //running = false;
                     running = 0;
                     break;
                 case SDL_KEYDOWN:
                     stdout.writeLine("Event: SDL_KEYDOWN");
                     //running = false;
                     running = 0;
                     break;
                 default:
                     stdout.writeLine("Event: %d".format(event.type));
             }
         }
     }

     //stderr.writeLine("running == " ~ (running==true ? "true" : "false"));
     stderr.writeLine("running == %d".format(running));

     stdout.writeLine("Shutting down...");

     return 0;
}

//////////////////////////////////////////////////////////////////////////////

Now *this* code works as expected, but if I change result to a bit (and 
use true/false instead of 1/0), it just drops out of the loop after 
processing two events (typed 17 and 1, which I believe are 
SDL_VIDEOEXPOSE and SDL_ACTIVEEVENT).  Sometimes I get a few mouse 
events (event.type == 4) instead of the ACTIVEEVENT, but VIDEOEXPOSE is 
always first.

Is this a bug in dmd, or is there something I'm missing?

For reference, I'm using the latest DerelictSDL and dmd under WXP.

	-- Daniel "What in the..."
Nov 15 2004