# code wont compile any more and ive gone crazy

## Recommended Posts

i know there are posts like this all the time (ive read some, but they did not help) my question is this.. is there ever a reason that code would just not compile any more... I am using msvc++ 2003 ... basically i changed like five lines of code (moved them from one file to another ) then wham.. I get about 1300 errors.. so i move it back...but the errors are still there.. not even a clean build fixes it. all the errors are saying my class are undefined.. ive spent the last 2 hours trying to figure out whats going on... so ive decided its not my fault(even though i know it is) but i feel its at least worth asking... sorry for the retard question.. thanks..

##### Share on other sites
Things can blow up suddenly if you accidently deleted or inserted a {, } or ; in the wrong place. Other than that, I don't think we can be much help.

##### Share on other sites
Check if you are editing the correct file, i.e. there isn't a second file with this name in your project. Maybe insert #error in your header file to see if it is parsed.

##### Share on other sites
yeah, that is totally what i think it is but i just cant find it...
There should really be a "I SCREWED MY CODE UP REAL BAD SO FIX IT" button

;P

##### Share on other sites
Source control is nice to have :)

Quote:
 my question is this.. is there ever a reason that code would just not compile any more...

Yes, there's a reason: You made a mistake somewhere ;)

Quote:
 all the errors are saying my class are undefined..

Are you using namespaces, and forgot to add them in the new file?
I have no other ideas.. (other than what SiCrane said..)

##### Share on other sites
well i found something and i dont even know what its saying

C2040: 'WereModel::GetMaterial' : 'int *(void)' differs in levels of indirection from 'void (void)'

the actuall function it complaning about looks like this
WereMaterial * GetMaterial(){return m_pMaterial;}

i know that this is not the root of my prob but its just looks strange

##### Share on other sites
First: I agree that source control is a Good Thing. If something blows up, you can always just back out to the last good configuration you checked in.

Second, here's how to diagnose your problem:

After you're done building, click on the "Output" window (no, not the "Tasks" window, the real build output window).

Scroll to the very top, and find the first error message that the compiler printed out.

What does that error message say?

##### Share on other sites
ok it does not really make sense why it says that to me but here it is

error C2146: syntax error : missing ';' before identifier 'm_timer'

here is what the code looks like up the error

#pragma once#define WIN32_LEAN_AND_MEAN#define VC_EXTRALEAN#include <windows.h>#include <d3d9.h>#include <d3dx9.h>#include <fstream>#include <string>#include "wereglobalincludes.h"class WereEngine{public:	WereTimer				m_timer;

also is there a way to specify the order in which files get compiled?
does it matter?

##### Share on other sites
The problem is probably somewhere in the wereglobalincludes.h file.

##### Share on other sites
Quote:
 Original post by MTcliperror C2146: syntax error : missing ';' before identifier 'm_timer'
You're possibly missing a ';' after a class or struct definition in another file. When I was first learning C++ I found those particularly easy to leave out.

##### Share on other sites
As Sicrane said, your problem is most likely in wereglobalincludes.h. If you have a class or struct in there make sure it has a ; on the end of the definition... Ex: class Foo { void FooBar(); };.

##### Share on other sites
well i finally got it to compile again...

the reason it would not compile does not really make sense to me but heres what was goin on ... in case any one cares ;P

the problem was between Object class and my Logger class
at first i thought that it may have been a cyclic thing, but i changed Logger so it did not inherit from Object.. same problem occured.. basically for some reason the Logger can not have Logger.h header included...

Here is the weird partjust by putting the #include Logger.h in the object class it caused c++ standard files to error such as..
excpt.h
stdarg.h
BaseTsd.h
... and many more

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628394
• Total Posts
2982428

• 10
• 9
• 19
• 24
• 9