Public Group

# visual c++ 2005 express can't compile my class

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I just installed and tried the new VC++ 2005 Express with MS Platform SDK... but the problem is that it can't compile my class, I created it with the built in class create tool Looks like this and should be compiled in a static library
------- C3DSFile.h
#pragma once

class C3DSFile
{
public:
C3DSFile(void);
~C3DSFile(void);
};

------- C3DSFile.cpp
#include "C3DSFile.h"
#include "StdAfx.h"

C3DSFile::C3DSFile(void)
{
}

C3DSFile::~C3DSFile(void)
{
}


I get this errors:
1>d:\my projects\c++ 2005 express\3dstudio library\3dslib\c3dsfile.cpp(20) : error C2653: 'C3DSFile' : is not a class or namespace name
1>d:\my projects\c++ 2005 express\3dstudio library\3dslib\c3dsfile.cpp(21) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\my projects\c++ 2005 express\3dstudio library\3dslib\c3dsfile.cpp(22) : warning C4508: 'C3DSFile' : function should return a value; 'void' return type assumed
1>d:\my projects\c++ 2005 express\3dstudio library\3dslib\c3dsfile.cpp(24) : error C2653: 'C3DSFile' : is not a class or namespace name
1>d:\my projects\c++ 2005 express\3dstudio library\3dslib\c3dsfile.cpp(24) : fatal error C1903: unable to recover from previous error(s); stopping compilation


I have compiled other things that works

##### Share on other sites
Lose the void in the contructor declaration and implementation

##### Share on other sites
IIRC you must
#include "stdafx.h"

Edit: And destructors take no arguments, not even one of void. I still fail to understand why VC++ generates such nonsensical argument types, escpecially when it isn't legal.

##### Share on other sites
Quote:
 Original post by PantherBoyLose the void in the contructor declaration and implementation

Read the c/c++ spec, void there is redundant but valid.

Quote:
 #include "StdAfx.h"

I think your problem relates to precompiled headers, although I can't seem to reproduce your exact problem. Try disabling them entirely and see if the project builds.

Alan

##### Share on other sites
please post more info about what else do you have in your application, because i compiled the entire Nebula Device 2 solution, and i've got only one error about an int declared in a for and used somewhere else(it looks like vc++ 2005 is more standard compliant). so maybe you have some mistake in your code or project settings.

##### Share on other sites
I only had what I wrote and an pre-created stdafx.h/.cpp file that Visual C++ created for me..

The problem is solved but I don't know what was wrong.. I recreated the class and now it works.. it still looks the same.. the void is there in the constructors and the stdafx.h is included after the other .h file

##### Share on other sites
I can't guarantee this is what you were experiencing, but: I have occassionally run into a problem compiling where it will work fine one moment, and then, without changing a single line of code, will fail a few times in a row... usually after cleaning the project or solution and compiling again it will work fine after that... occassionally it still won't work, in which case, just modify one of the open source files and save it again (dont actually change any code, just do something like create a space and then delete the space) - then it will compile fine again.

I have no idea what triggers this problem sometimes and not others (I haven't kept close enough track of what I'm doing before it happens) but it can cause some real headaches =P

Again, this may not have been what youy were experiencing

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 29
• 15
• 41
• ### Forum Statistics

• Total Topics
634838
• Total Posts
3019568
×