Problems with VS2008 Pro

Started by
8 comments, last by wicked357 14 years, 1 month ago
I am using VS2008 on Vista 32bit, and I have been using on this laptop for quite awhile some months now, well I haven't used classes in awhile and I am trying to get back in the swing of using them, but something is wrong, and I need to know if it is a setting in VS2008 or should I reinstall it. My problem is I have a header file in an include folder called settings.h, in it is a class, just to be sure I wasn't doing something wrong I even used a completely basic tutorial class in this case CRectangle, "include/Settings.h"

class CRectangle
{
public:
    void set_values(int a, int b) { x = a; y = b; }
    int area() { return (x*y); }
private:
    int x, y;
};

"Main.cpp"

#include "include/settings.h"

int main(int argv, char* argc[])
{
    CRectangle rect;

    return 0;
}

Now my problem I get 3 errors from this, 1st: 'CRectangle' : undeclared identifier 2nd: syntax error : missing ';' before identifier 'rect' 3rd: 'rect' : undeclared identifier Now this has to be a problem with my VS2008 Pro compiler, right? Or am I just having the biggest brain fart of all time, if it is VS2008 is there a setting to fix this or should I reinstall it, BTW I have Visual AssistX installed, but it is installed on both machines. I have noticed another problem, even VAssistX isn't working properly, for instance on my main rig it will recognize any Box2D functions, variables, etc... and give me the drop down of choices within the scope of what I am typing, but on the laptop with the problems it doesn't recognize only Box2D stuff so I will not get the intellisense but only for Box2D stuff. This is obviously a VAssistX problem, but I am trying to avoid the long process of installing VS2008 all over again. Thank you in advance for any help.
Advertisement
You're including "include/settings.h", but the file is called "include/Settings.h" according to you.

Are you sure you're being consistent with the capital S?
Yes I am sure, actually I have more information in this header aside from that example class I tried and all works fine until I try and declare it in my main.

**Edit: Oh yea, I tried that same class example so I had that right, it works perfect on my main rig, so it is definitely my compiler, so is there a setting that would fix this or am I screwed and have to reinstall my VS2008 all over again along with VAssistX?
You're almost certainly looking at/#including the wrong file(s) somehow, or looking at stale messages from a previous build.

Build -> Build Solution. Do the error messages remain?

Close all open files.
Double click the error. It this the right main.cpp?
Right click on the filename on the #include line. Select the first menu item, "Open Document "include/settings.h"". Is this the right settings.h?
I agree with the previous posters, it is most likely related to your folder structure. please make sure that is completely valid first off.

Next, I do recall having a very similar error a very long time ago (in VS2003 I believe), and that had to do with a strange glitch involving precompiled headers. I solved this by disabling precompiled headers, and rebuilding the project. I doubt its the case, but I would try that before reinstalling VS.
Quote:Original post by Gauvir_Mucca
You're including "include/settings.h", but the file is called "include/Settings.h" according to you.

Are you sure you're being consistent with the capital S?


Character cases in the Win32 filesystem are irrelevant. MyFile.txt, myFILE.txt, myfile.txt and myFiLE.TXt are considered to be the same name on Windows as opposed to all posix standard systems (UNIX/Linux/OSX/BSD/Etc.) where these would be four different files each with a unique name.

-Lead developer for OutpostHD

http://www.lairworks.com

Okay! I have cleaned the solution and rebuilt the solution before you even gave me the idea, it comes up with the same error over and over, I have even closed out VS2008 and reopened it. I have the same issue, undeclared identifier, and as I stated in my previous post this header file has other settings in it and I use them, without it I would get a whole lot more errors than this, I just added the class in there because I knew that header was right and I didn't want to create a new header for a sample class. I thought it was my class before since it was more advanced than this and I thought maybe I completely forgot how to make a proper class but I didn't the compiler isn't recognizing it at all, it won't give build errors until I try and declare it.
I can't see the whole header file from here, but did you make sure that the CRectangle declaration isn't inside a #ifndef / #ifdef block that would prevent the compiler to see it.

I would try to move the declaration of CRectangle to a separate header file or even in Main.cpp itself, just before main(), to see if this is really a Visual Studio's error (might be, but unlikely.)
Try using this:
#error "CRectangle declaration"class CRectangle {// ... etc

If it causes your compiler to stop on error, then the correct Settings.h is included. If not, then it isn't and you should search your include paths for other Settings.h files.
Hah! I feel dumb I completely spaced out the class was in an #ifndef block, thanks for the point out I guess if I would have posted the whole file I would have got this answer earlier sorry for not posting the entire source I just didn't want to clutter up to many lines of code to look at. Thank again, everything is working fine now.

This topic is closed to new replies.

Advertisement