SamY
SamY

Reputation: 88

Undeclared identifier error C2065 of definitions, that are clearly there

I am working with multiple projects, where I use header files of one project inside the other.

Now I added a project to the C/C++ Additional Include Directories, but after that I get this error with declarations that are all in the resource.h file.

My guess is that because both projects use a resource.h, it confuses them. The resource.h files are different from each other.

So if it is this problem what can I do to stop this?

Edit: I'll try to make an example, since I can't post the original code here.

OK I got 2 Projects:

MixedMfc:
<-file1. cpp
<-file2. cpp
<-file3. cpp

<-file1.h
<-file2.h
<-file3.h
<-resource.h

NativeCaller:
<-file4.cpp
<-file5.cpp
<-file6.cpp

<-file4.h
<-file5.h
<-file6.h
<-resource.h

every header file has an #include "resource.h" (except the resource.h files)

the first resource.h looks like this:

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.

the second has a bunch of defines

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
#define VALUE1 1
#define VALUE2 2
#define VALUE3 3
#define VALUE4 4
#define VALUE5 5

Thanks

Upvotes: 0

Views: 1555

Answers (1)

twsaef
twsaef

Reputation: 2121

This problem is often solved by setting a higher level directory as the Visual Studio include directory, and including files in the format of

#include "boost/lexical_cast.hpp"
#include "SFML/Graphics.hpp"

or in your case

#include "project1/resource.h"

vs

#include "project2/resource.h"

Or are you just able to remove the empty resource.h from your project and delete it from your file system?

Upvotes: 2

Related Questions