Advertisement

What to do when your code blows up....

Started by September 16, 2002 04:41 PM
13 comments, last by Radagar 22 years, 1 month ago
GRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHHWWWWWWWWWWWWWW!! Ok, I broke my program. I don''t know what I did, but I have over 150 compiler errors that I can''t get rid of. I''ve been over every line at least twice, and everything looks perfect. The lines that are reporting errors shouldn''t be erroring out. Especially since they were working 3 hours ago and haven''t been changed. I''ve tried cleaning and rebuilding the workspace from scratch, No Good... So now I''m about to throw my computer out the window. Any suggestions?? Basically, Everywhere that I try to use a class or enum''d type, the compiler isn''t recognizing it. All my header files are included and have inclusion guards so they aren''t added in twice... I can''t find any missing semi-colons or braces. It''s driving me crazy! I''m not going to post all 24 files or 1000+ lines of code, but if anyone has any suggestions on how to track down an invisible typo or bug that would cause symptoms like this, please tell. ~~~~~~~~~~~ Chris Vogel ~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
Maybe it would help if you posted the first few errors the compiler is giving you. I had a problem that took me a little while to find where one of my inclusion guards said "ifdef" instead of "ifndef".
Advertisement
Usually when i suddenly get more then 100 errors when everything was fine before its a missing closing bracket or a missing ; somewhere.
Check especially class declarations and make sure they all end with };

Edit: sorry, didn't see you already said that you already checked for those.


Runicsoft -- home of my open source Function Parser and more

[edited by - Burning_Ice on September 16, 2002 5:53:49 PM]
quote: Original post by Radagar
So now I''m about to throw my computer out the window. Any suggestions??

Open the window first.

Hehe, seriously, when I run into a problem that I can''t seem to solve, I walk away. Go to your nearest 7-11, grab a cherry-flavored brain freezy (or whatever they''re called), call up some friends and talk about non-computer related issues, maybe catch some cartoons on TV... then sit down and mess with your program. I know it sounds silly, but it really works. Taking a break is the best way (IMO) to fix a frustrating problem.

- Jay

"I have head-explody!!!" - NNY

Get Tranced!
Quit screwin' around! - Brock Samson
Ok....

I have these classes defined in seperate .h files

CWorld in CWorld.h
CEnemy in CEnemy.h
CEncounter in CEncounter.h
CItem in CItem.h
CParty in CParty.h
CPlayer in CPlayer.h

I then have these seperate .h files
Function.h, Input.h, AI.h, Wyrm.h, Globals.h

Every .h file has a corresponding .cpp file

Wyrm.cpp is my main file.

The first 3 of the 155 errors are..
cmap.h(6) : error C2065: ''CWorld'' : undeclared identifier
cmap.h(6) : error C2065: ''worldstate'' : undeclared identifier
cmap.h(6) : error C2182: ''CreateMap'' : illegal use of type ''void''

CMap.h #includes "CWorld.h" worldstate is defined as a member of CWorld and the definition of CreateMap looks like this
void CreateMap( CWorld *worldstate ); 


I went through and made sure all my #ifndef''s were right. I checked all classes for ending in } and ;. All looks good so far.


~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development
quote: The first 3 of the 155 errors are..
cmap.h(6) : error C2065: ''CWorld'' : undeclared identifier
cmap.h(6) : error C2065: ''worldstate'' : undeclared identifier
cmap.h(6) : error C2182: ''CreateMap'' : illegal use of type ''void''

CMap.h #includes "CWorld.h" worldstate is defined as a member of CWorld and the definition of CreateMap looks like this

void CreateMap( CWorld *worldstate );


I don''t think you can pass member variables to functions. You probably need to pass a reference to a class object or put a scope identifier on the variable.

John.
Advertisement
for fun could you post 3 of your #ifndef blocks (not the code in between just the full #ifndef/#define/#endif blocks)? a hesitant guess is that somehow a few of them have the same names for the #define so you''re not actually ending up including all of them.

alternately, have you moved some files into different directories? though i guess it''d then be throwing include file xxx.h not found errors....

-me
Ahhh. OK. So your CWorld class has a variable called worldstate of type integer or whatever? What you are trying to do in your CreateMap function is to send an instance of (or in this case a pointer to...) your CWorld class. Now, worldstate is a variable of that class. It is not of type CWorld (if it is, disregard my post). It might have just been a typo, so if it is, disregard my post. What your function declaration should look like is:

void CreateMap(CWorld World);

and then in your definition:

...
World.getState() // or whatever
...
quote: Original post by Sheep
Ahhh. OK. So your CWorld class has a variable called worldstate of type integer or whatever? What you are trying to do in your CreateMap function is to send an instance of (or in this case a pointer to...) your CWorld class. Now, worldstate is a variable of that class. It is not of type CWorld (if it is, disregard my post). It might have just been a typo, so if it is, disregard my post. What your function declaration should look like is:

void CreateMap(CWorld World);

and then in your definition:

...
World.getState() // or whatever
...


that is all true, but it doesn''t explain the compiler errors he is getting. the compiler should at least be able to find class CWorld no matter if he is or is not using it correctly.

it should certainly all be fixed, otherwise there will be massive errors later at runtime...

-me
quote: Original post by Sheep
Ahhh. OK. So your CWorld class has a variable called worldstate of type integer or whatever? What you are trying to do in your CreateMap function is to send an instance of (or in this case a pointer to...) your CWorld class. Now, worldstate is a variable of that class. It is not of type CWorld (if it is, disregard my post). It might have just been a typo, so if it is, disregard my post. What your function declaration should look like is:

void CreateMap(CWorld World);

and then in your definition:

...
World.getState() // or whatever
...


Was a typo. Thanks though. gamestate is actually an instance of CWorld

~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
WyrmSlayer RPG - In Early Development

This topic is closed to new replies.

Advertisement