The f'n compiler is picking on MY code!!!

Started by
4 comments, last by wombatvvv 21 years, 7 months ago
If someone can explain this one to me I''d be surprised. I''m doing Marius'' SDL tutorials, and got a whole heap of errors when I tried compiling the third one. By a process of trial and error, I''ve nailed the buggy code down to just a handful of lines in my CSprite.h header file. If I copy those lines out of Marius'' (the tutorial authors) example source code, and paste into my header file, over the buggy code, this fixes the problem and the progeam compiles fine. The astonishing thing is, the code I''m copying & pasteing is EXACTLY the same as the code I''m overwriting!!! The below blocks are directly cut&paste from my code and his code respectively: "Buggy" Code: int mFrame; int mX, mY, mOldX, mOldY; int mAnimating; int mDrawn; float mSpeed; long mLastUpdate; CSpriteBase *mSpriteBase; SDL_Surface *mBackreplacement; SDL_Surface *mScreen; Original working Source Code from tutorial author: int mFrame; int mX, mY, mOldX, mOldY; int mAnimating; int mDrawn; float mSpeed; long mLastupdate; CSpriteBase *mSpriteBase; SDL_Surface *mBackreplacement; SDL_Surface *mScreen; What in the hell is going on here!!??? I''m tearing my hair out in frustration here, this must be some sort of stupid compiler problem. I can cut & paste his code right underneith mine, ensuring every line is exactly the same. If I delete my block and compile it works fine. If I delete his block and compile I get 3 errors. I''m using the Dev-C++ compiler on Windows XP. The errors are: 55 csprite.cpp `mLastupdate'' undeclared (first use this function) 55 csprite.cpp (Each undeclared identifier is reported only once 55 csprite.cpp for each function it appears in.)
Advertisement
It''s easy to explain: in your code you have mLastUpdate, with capitalized U, and in the original code the u isn''t capitalized. This is your problem.
I think it''s just a typo, there''s no capital U in one of your references to mLastUpdate.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
wombatvvv:

C/C++ is case sensitive, so mLastUpdate != mLastupdate. The errors that you''re getting are diagnostic enough to tell you what''s going on.

John.
Please forgive me tired clumsiness. God knows how I possibly missed that, especially when the error message was telling it to me directly. I feel like an idiot - and, I guess I am.

The thing is, I initially got about 30 errors from a much bigger block of code. I couldn't pick any of them, and none of them where that easy, I assure you. I just gave up finding them (even though I had compared our code line-by-line). Instead of cutting and pasteing the whole header file, I tried to narrow it down to just a few lines to show what I was talking about. Unfortunately, I just assumed these lines were throwing the same "weird" errors as the rest of the code, but I was wrong. The error here, as everyone has noticed, is blatant and simple. I really had compared each line, line-by-line and was getting some really, really odd errors - HONESTLY! It's just that little block I chose to exemplify it was the wrong little block of code.

Having said that, considering I missed that error (above), I'm the first to admit I could have been skimming over equally obvious stuff. I just had a mindset. I'm still absolutely flabbergasted that I was dumb enough to post that one.

[edited by - wombatvvv on August 31, 2002 8:48:02 PM]
You are not an idiot we have all made mistakes like that. You might want to try using some file comparison tools when you have a problem like that. There are allot of free ones around the only one I can recomend is diff which you can find on most Unix machines you can download cygwin if you want to run diff on a Windows machine.

This topic is closed to new replies.

Advertisement