Jump to content
  • Advertisement
Sign in to follow this  
jimi_hendrix

Why is this segfaulting???

This topic is 3665 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 am using SDL this code compiles but segfaults on startup I have been trying all morning but cannot find the segfault...i have noticed that it will run if you comment line 109... other segfaults...when the stars hit the bottom of the screen and if you hit spacbar (because i have not finished that part...) but the screen one bottles me too this is my first big(as in a lot of lines) program in C++ pastebin for code http://pastebin.com/m32c4319c

Share this post


Link to post
Share on other sites
Advertisement
Well, I'm not sure. Where does the debugger tell you the segfault is, and why does it tell you the segfault is happening?

Share this post


Link to post
Share on other sites
Okay, that's pretty much what I said you shouldn't do.

Have you checked for dereferencing uninitialized or null pointers?
Have you set break points, what does your debugger say?

Share this post


Link to post
Share on other sites
@Snef

i am using g++ in linux...so it just says Segmentation Fault...i put in a cout statement in there to see if i even get that far and i dont

i think it has to do with the missile class or its instatiation in the player class

@Wan

what else do you want to know?

Share this post


Link to post
Share on other sites
Quote:
Original post by jimi_hendrix
i am using g++ in linux...so it just says Segmentation Fault...i put in a cout statement in there to see if i even get that far and i dont
Right. Because you're not running it in the debugger. Run it in the debugger. It's for debugging.

Just to make things a little clearer: A programmer trying to find a segfault somewhere in a large block of code is like a carpenter trying really hard to push a nail into a piece of wood with his hands. And when he can't, he posts "hey, can anyone push in this nail with their hands? I can't get it in!" on a message board. We don't push nails in with our hands. We use hammers. Learn to use your debugger.

Share this post


Link to post
Share on other sites
More precisely, read Debugging with gdb, which is the debugger that you will want to use with g++. Or, just use an IDE that takes care of the debugger handling, such as Eclipse or Code::Blocks, then it all comes down to pressing one button.

Share this post


Link to post
Share on other sites
ok

so now after removing multiple segfaults i have a segfault in the SDL_DisplayFormat() in loadImage()...this did not segfault before...why would it segfault now?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!