MyPrecomp.h
#include "StdAfx.h"
#include "MyGlobals.h"
#include "SomeOtherStuff.h"
"MyGlobals.h" includes various bits, such as <new>, <algorithm>, and
<limits>.
I also have a file called MyPrecomp.cpp. In the Project properties, I set
the /Yu flag, and I specify that the precompiled header is to go through the
file "MyPrecomp.h", and that the actual precompiled header file will be
"MyPrecomp.pch".
I the properties for MyPrecomp.cpp, I set the /Yc flag, and use the same
specifications for "going through" and the pch file as above.
When I try to build, the compiler grabs MyPrecomp.cpp and starts compiling
it, sucking in the headers, and then generates the following error message:
C:\Program Files\[...]\atlcoll.h(1953): error C2857: '#include' statement
specified with the /YcG:\Development\[...]\MyPrecomp.h command-line option
was not found in the source file.
So, what's going on here? Why is atlcoll.h, a header file, complaining about
my precompiled header file? And what does some file down in ATL have to do
with anything?
nomad:
I don't think you are supposed to put the stdafx.h in another header;
rather you are supposed to put it first in each .cpp file. Does the
problem go away if you do that?
David Wilkinson
"David Wilkinson" wrote:
> I don't think you are supposed to put the stdafx.h in another header;
> rather you are supposed to put it first in each .cpp file. Does the
> problem go away if you do that?
Nope. I changed the setup as follows:
StdAfx.h
#include "MyGlobals.h"
and modified MyGlobals.h to not include StdAfx.h anymore. I renamed my old
MyGlobals.cpp file to be StdAfx.cpp and set its properties the same way. I
get the exact same error message.
"nomad" wrote:
> I get the exact same error message.
Well, except that it's complaining about not finding StdAfx.h now instead of
MyPrecomp.h.
In my properties, I had specified the "through file" specification as
$(ProjectDir)MyPrecomp.h
If I specify it instead as
MyPrecomp.h
i.e., leave off the "$(ProjectDir)", everything works. This may have to do
with the fact that my project directory is on my G: drive, not my C: drive,
or it may be because something in the IDE doesn't like the $(ProjectDir)
macro at that point. In any event, this seems to have fixed it.
Only took me a day and a half to track down. Geez, what a crock.