#### Archived

This topic is now archived and is closed to further replies.

# Help with SDL Error Please!

This topic is 5224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know this is going to be very simple for someone but I cannot set the problem for myself. I can compile the code below and it compiles without errors or warningings, but when I run it I get the error: "Run-Time check failure #3 The variable event is being used without being defined" void CTWGame:lay() { int done=0; while(done == 0) { SDL_Event *event; while(SDL_PollEvent(event)) { if (event->type == SDL_QUIT) done =1; } DrawScene(); } } Any Ideas???

##### Share on other sites
The way you''re using SDL_PollEvent is non kosher. Either pass it the address of a valid event structure, or pass it null. i.e.:

SDL_Event event;
while (SDL_PollEvent(&event)) {

##### Share on other sites
SDL_Event *event;
while(SDL_PollEvent(event))

needs to be

SDL_Event event;
while(SDL_PollEvent(&event))

##### Share on other sites
I have tried both of the above and now come back with errors at compile time. Perhaps I am being a bit retarded here.

I now get
"SDL_Event" does not have an overloaded member operator ->

left of''->type> must point to class/struct/union

I know I am missing something here.

##### Share on other sites
You can use event.type instead of event->type.
Or, if you insist on using a pointer the whole time, you can leave it the way you had it before and change the beginning to
SDL_Event *event=new SDL_Event(); //I'm not positive about this                                  //syntax, I've being using Java                                  //recentlywhile(SDL_PollEvent(event))

Zorx (a Puzzle Bobble clone)
Discontinuity (an animation system for POV-Ray)

[edited by - clum on June 2, 2004 10:21:11 AM]

##### Share on other sites
Thanks Clum

Thats sorted the problem.

I dont envy you with Java, I have never managed to get on with, but perhaps one day I will return to it.

##### Share on other sites
quote:
Original post by Helsing
I have tried both of the above and now come back with errors at compile time. Perhaps I am being a bit retarded here.

I now get
"SDL_Event" does not have an overloaded member operator ->

left of''->type> must point to class/struct/union

I know I am missing something here.

Check out what line you get that error at. When the object is a pointer, you use the -> operator, if not you use the . operator. Try changing event->type into event.type

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
15
5. 5

• 10
• 9
• 13
• 9
• 33
• ### Forum Statistics

• Total Topics
632592
• Total Posts
3007290

×