Jump to content
  • Advertisement

Archived

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

Helsing

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
SDL_Event *event;
while(SDL_PollEvent(event))

needs to be

SDL_Event event;
while(SDL_PollEvent(&event))

Share this post


Link to post
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 this post


Link to post
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
//recently
while(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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!