Jump to content
  • Advertisement
Sign in to follow this  
ViperG

Out of Vector Scope

This topic is 4834 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 was using visual studio 6 fine, but now that I switched over to 2005 visual studio, one of my vectors is reporting it's being called out of scope. where size() <= pos It doesnt tell me which one though. Is there a way to find out which vector is making a call our of scope? basicly I cycle through my vectors like
for (int x=0; x < vector.size();x++)
	{
		<Vector stuff here>
		
			if (vector[x]->alive==false)
			{
				delete vector[x];
				vector[x].erase(vector[x].begin() + index);
				--x;
			}
		
	}


[Edited by - ViperG on August 22, 2005 11:35:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
Well, you can step through your code, line by line with a debugger to find where it is.

Also, a good idea would be to check wherever one is being referenced. If you find one where you don't have a check that "pos < size()", I'll be betting that that'll be your problem.

Share this post


Link to post
Share on other sites
in visual C++ 2005, when the debugger breaks showing the sunscript of of range window, check the call stack, this'll lead you to know which vector caused the error exactly when.

Share this post


Link to post
Share on other sites
Yeah I just figured it out, its freaking way cooler than Visual Studio 6.

At first I didn't get it, because after my game would crash, I would close the window, but then all my debug information went away.

And I didn't see the debug information, because my game makes the resolution smaller, so when it alt tabs back to VS, the screen is all big, u know.

So anyways, I found it, and seriously, I love how you can go through all of vector with a tree like directory, and look at all the data.

I use vectors inside vectors, and I could browse through all that too no problem.

I'm already liking 2005 way more. But it sure likes to use alot of my screen. I'm hiding the lower window and the side window. and the tabbed browsing is ok I guess. I need to get used to that, or see if I can customize it better.

But I fixed the problem, games not crashing and I have no bugs. But I do have 465 warnings, it's really annoying.

oh yeah I have a question about these lame warnings!

warning C4018: '<' : signed/unsigned mismatch
warning C4996: 'strcmpi' was declared deprecated
warning C4996: 'strcpy' was declared deprecated
warning C4244: '=' : conversion from 'int' to 'float', possible loss of data

honestly why do I need these warnings.
can someone help me here they are annoying.

and are their replacement functions for the deprecated functions or what the heck do I do?

Share this post


Link to post
Share on other sites
Warnings help you avoid minor mistakes when running the code. For example, rounding off a float if it was considered as an integer, may give different results. At the beginning of coding, it's safe to avoid those warnings and event set the warning level to lowest, but at the end you need to make sure you know what each warning is about and if it's safe to avoid it entirely. For example, here are your warnings:

warning C4018: '<' : signed/unsigned mismatch - in comparision operator, as I said, signed and unsigned have their limits, thus it is unsafe to assume they are always are going to be within those limits.

warning C4996: 'strcmpi' was declared deprecated - you can use this function, but it's better be replaced with the newer one.
warning C4996: 'strcpy' was declared deprecated - same as above...
warning C4244: '=' : conversion from 'int' to 'float', possible loss of data - possible loss of data will occur (but I don't understand how). I understand if you convert float to an int, but not other way around. Anyway, what it says is that you may lose some precision when converting from one type to another.

Thats it.

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.

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!