Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / [LOCKED] Odd variable declaration error...

Author
Message
Siolis
18
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 10th Feb 2007 17:41 Edited at: 10th Feb 2007 17:51

Quote: "
.main.cpp(126) : error C2065: 'TPCSetter' : undeclared identifier"


Anyone care to attempt to explain this?

(ps: I used a char pointer when an int didn’t work. I chose a char pointer as they worked fine respectively earlier in the program.

EDIT: Not sure why but i had to declare the varible outside of an if statement before it would work, meh.

A Dragons Legacy...a blog by S.R.Deoden
"Look you son of a suitcase..." - Rinsewind yelling at the Luggage in The Light Fantastic
HandK
18
Years of Service
User Offline
Joined: 24th Jun 2006
Location:
Posted: 10th Feb 2007 20:23 Edited at: 10th Feb 2007 20:33
Ok, this is a simple mistake to make, but it is a lesson to be learnt.

Please look at the scope of TPCSetter, it is defined within the If Block, and so it only exists within the If block.
---------------------------------------------------------------------------
Problem solved? Possibly Not!

The problem (And Im only assuming this from you indentation), is that you have ended the If block too early.

I think what you wanted to do was run the second if, only if the first if was true.

In this case the closing brace } for the first if should be at the end, and not after the TPCSetter decleration.

In this way TPCSetter will still only have scope in the ifblock, but the second if will also be in this block
---------------------------------------------------------------------------
Obviously this is just an assumtion of mine, but eitherway you need to make sure that TPCSetter is defined at a high enough scope to contain both the if statements.

If my assumption was wrong, then as you have done in simply moving TPCSetter to outside the ifs will be enough.

H&K
Siolis
18
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 11th Feb 2007 23:09
Completely wrong and I’m aware of how to write function statements, I just didn’t take into account the scope clause of IF statements.

The point was that TPCSetter gets set to one if ScanCodeHold is set to three. ScanCodeHold is set to three if the second numerical button is pressed to activate the second camera mode. If TPCSetter is set to one then an if statement, within the second camera mode if statement, sets the Third Person Camera Prospective (as in Third Person Camera Setter, TPCSetter) to behind the character object, which is currently a cube. This only needs doing once when the second numerical button is pressed, as in upon activation of the camera mode; otherwise it affects the character controls.

You were correct in saying that I need to declare TPCSetter outside of any IF statements for the scope to be used throughout the remaining IF statements though.

A Dragons Legacy...a blog by S.R.Deoden
"Look you son of a suitcase..." - Rinsewind yelling at the Luggage in The Light Fantastic
HandK
18
Years of Service
User Offline
Joined: 24th Jun 2006
Location:
Posted: 12th Feb 2007 14:40
Quote: "Completely wrong"

Oh well.

You have completly rubbish indentation then

(I didnt think it was that, otherwise you wouldnt need two ifs at all, but I wanted to add the extending the scope bit for others when they search the threads)

H&K
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 12th Feb 2007 15:05
Ok cool, that problem's solved

Paul.

Login to post a reply

Server time is: 2024-09-27 17:29:35
Your offset time is: 2024-09-27 17:29:35