473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why isn't this variable considered "in scope"?

I am making a map generator and for some bizarre reason I have a variable
that will not come in scope.

Code snippet:

void placeContinents(int NumberOfContinents)
{

for(int Loop = 0; Loop < NumberOfContinents; Loop++)
{
// Get a random X co-ordinate
int ContinentX = (int)((pRND->NextDouble() * _MapWidth) - 0.5);
int ContinentY; // <---------------- ***** It's this one.**********

for(;;)
{
// Get a random Y co-ordinate
int CandidateY = (int)(pRND->NextDouble() * (double)_MapHeight -
(double)0.5);
ContinentY = CandidateY;
double RndNum = pRND->NextDouble();

// Find a tile close enough to the equator...
if(equatorDistance(CandidateY) > (double)0.81999999999999998 +
(double)0.17999999999999999 * RndNum)
break;
}

// ...set a continent marker.
mapGrid->SetValue((char)TileType::GRASS_NORMAL, ContinentX, ContinentY);
}
}

The debugger won't see it and their doesn't appear to be any amount of
declaring I can do to make it show up. I've tried declaring it at the top
of the method, in the first for loop, in the second for loop... I've tried
a while loop I've tried a for(;;) loop...I can't even set breakpoints on it.
When I right click in the IDE and select "Goto Definition" it says it's not
defined, even if I do it to the variable name in the declaration itself!

I cannot, for the life of me get this thing to recognize that variable.

What am I doing wrong?

Thanks,
Tom P.
Dec 12 '05 #1
3 1187
>I am making a map generator and for some bizarre reason I have a variable
that will not come in scope. The debugger won't see it and their doesn't appear to be any amount of
declaring I can do to make it show up.


Tom,

Are you debugging an optimised version of your code?

What you're experiencing is common in optimised builds.

Dave
Dec 12 '05 #2

"David Lowndes" <Da****@example.invalid> wrote in message
news:47********************************@4ax.com...
I am making a map generator and for some bizarre reason I have a variable
that will not come in scope.

The debugger won't see it and their doesn't appear to be any amount of
declaring I can do to make it show up.


Tom,

Are you debugging an optimised version of your code?

What you're experiencing is common in optimised builds.

Dave


Umm, how do I determine that and how do I make it stop?

I'm coming back to this after a while in C# and it's gotten a little weird.
I was never very good at it and now I have this managed stuff to figure out
too. Thanks for the help.

Tom P.
Dec 12 '05 #3
>> What you're experiencing is common in optimised builds.

Umm, how do I determine that and how do I make it stop?


Project property pages, C++ , Optimization tab.

You're only guaranteed to make sense of things when debugging with the
/Od option.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Dec 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lu | last post by:
Hello, I am wondering how to protect a global variable in a header file from external access. So I googled and found: "The keyword 'static' has two different uses, depending on whether it is...
9
by: Robbie Hatley | last post by:
Greetings, group. I just found a weird problem in a program where a variable declared in a {block} after a "case" keyword was being treated as having value 0 even though its actual value should...
7
by: sami | last post by:
Hi I am trying to write a facebook application in python - I have been programming simple desktop applications till now and am not really familiar with web apps Pyfacebook is the wrapper for...
4
by: fran7 | last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.