I am getting this error even though a) the header file does exist and is located in the directory and it's not somehow been switched to read only. Also, my #include statement uses "" like "test.h" so the compiler knows to look in the project directory first.

I've read that perhaps it has to do with the pch stdafx.h or stdafx.cpp and I've looked in project settings and it is set to use precompiled header through stdafx.h.

So what should I look into/try next?

Is the problem that the #include "test.h" gets called before the pch stdafx.h?

Thanks, I'm adapting code from a larger project and I'm clueless on this one.

Since you are using precompiled headers, stdafx.h must be the first include file in stdafx.cpp and all other *.cpp files of the project. Other *.h files can be included after stdafx.h and will not be included in the *.pch precompiled header file.

I don't think that is the problem though because the compiler would have given a different error message. So the only other possibility is that test.h is not located in the directory you think it is. It should be in the same folder as the other project .cpp files.

Just wanted to post a follow up. Thank you ancient dragon. You were correct. The compiler was unable to find the test.h header because it was located in a subdirectory of the project directory. I thought this would be remedied by adding the header file to the project, but it was still unable to find it. The solution to the problem was to replace

#include "test.h"


#include "..\subdirectory\test.h"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.