Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!
I am working on a project in Visual Studio 2008. It has over 50 classes divided in folders and subfolders. Everything compiled nicely except two lines:

MSIL
RandomTimedFlowElement.cpp
d:\c++_projects\projekat2010\pr2010\projekat_2010_1.0\concepts\abstract concepts\randomtimedflowelement.cpp(22) : error C2653: 'Event' : is not a class or namespace name
d:\c++_projects\projekat2010\pr2010\projekat_2010_1.0\concepts\abstract concepts\randomtimedflowelement.cpp(22) : error C3861: 'create': identifier not found


Event class is in Event.h and create() is static function in Event class.
This is strange because I included this class regularly and this cpp file doesn't see it. They are not in the same folder but when they are everything is OK.
So what should I do because I can't move .h file? It is needed in some other class also. I set include paths but the problem remains.
Why compiler doesn't just say: Event.h cannot open such file or directory ... but gives me these errors.
Please help.
This is the RandomTimedFlowElement.cpp:

// Class RandomTimedFlowElement 


#include "RandomTimedFlowElement.h"
// Event
#include "Event.h"

RandomTimedFlowElement::~RandomTimedFlowElement ()
{

}

// Other Operations (implementation)
void RandomTimedFlowElement::raiseEvent (ID id)
{
	Time tm = 0;
	tm = getTime(id);
	Event::create(this,tm,id);
}
Posted
Updated 19-Aug-10 15:46pm
v4

This one file must not be seeing your include file, make sure you include it using a correct relative path, in this file.
 
Share this answer
 
Comments
empnik 19-Aug-10 21:40pm    
Can you be more precise please? I set absolute path to every subfolder in project trying to find the problem but nothing... I will attach .cpp
Yes I know it doesn't see include file but don't know why. Other cpp file which is using it in the same folder as the include file works normally.
Nikola
Christian Graus 19-Aug-10 22:13pm    
I don't know how to be more precise. The file you're talking about, needs to include this file. This is not C#, what other files do, is irrelevant, unless you include a file that includes this file, but it's better to do it explicitly, to be safe.
CPallini 20-Aug-10 5:26am    
You may use the /E compiler switch and then just compile the file to see actual preprocessor output.
#include "RandomTimedFlowElement.h"
// Event
#include "Event.h"


What do you have in RandomTimedFlowElement.h, check all your definitions. May be some thing is messed up there. I have seen cases where some definiton that is not complete in header file will cause strange problems.


What happens if you change it to

// Event
#include "Event.h"

#include "RandomTimedFlowElement.h"
 
Share this answer
 
Event.h is actually a very popular name for a file. Make sure you are including the correct one.

Edit: It could also be that your two included header files have the same include guard like
C++
#ifndef FILE_H
#define FILE_H
(declaration)
#endif

A not so uncommon copy & paste problem.
 
Share this answer
 
v2
Comments
empnik 21-Aug-10 15:10pm    
I finally solved it. It was something wrong with my include paths. First I had absolute paths to every folder.
But compiler just couldn't find the Event class. I deleted all include paths and entered knew ones but this time used relative paths instead. First entered the paths to folders and after these to subfolders and project compiled nicely. Don't know why. Anyway I'm happy. Thanks everyone.
Nikola

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900