Jump to content
  • Advertisement
Sign in to follow this  
McZ

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
IIRC you must
#include "stdafx.h"
before everything else. Have you tried switching header inclusion order already?

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 this post


Link to post
Share on other sites
Quote:
Original post by PantherBoy
Lose 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!