Background...
- Code project in C++
- Project uses a precomp.h precompiled header
- Project contains Foo.h and Foo.cpp
- Foo.h does not reference precomp.h
- Foo.cpp starts with
#include "precomp.h"
and#include "Foo.h"
- No build issues
Problem...
- I am working on adding Bar.h and Bar.cpp to add a new functionality set, architecturally similar to what is in Foo.h/.cpp, and in the same directory
- Mirroring Foo, I do not include precomp.h in Bar.h, and include precomp.h and Bar.h in Bar.cpp
- I added Bar.h and Bar.cpp to the .vcxproj file the same way that Foo.h and Foo.cpp are added
- The same build type that passes before my addition of Bar fails once I add Bar.h/.cpp with the error in the title (
error C1010: unexpected end of file while looking for precompiled header
)
Question...
I've tried a number of different combinations to try to get this to work, but I am confused why Foo is not giving the same problems that Bar is. Is there some subtlety that I am missing? What sneaky difference should I be looking for? From all I can tell, everything relevant to this is set up the same way for both Foo and Bar.
What I've Tried, and What I Expect...
I've tried shuffling around the include statements (many attempts at which resulted in piles of nasty errors that indicate that's definitely not the way to do it). Given that Foo works with the include structure it has, I expect it to work the same way for Bar, and I want to do it the same way for Bar for consistency across the project.
Other info...
- I'm doing a very thorough clean/rebuild every time, so any weird state issues should be able to be eliminated as the cause
- Both Foo.h and Bar.h include
#pragma once
at the top, FWIW - This project is already set up to use precompiled headers, so presumably whatever is the issue should be specific to the files I'm adding (and the error is specifically referencing Bar.h)
Thanks in advance!
EDIT: Adding full error here for clarity...
"D:\src\[PATH1]\[PARENT].vcxproj" (default target) (1) ->
"D:\src\[PATH2]\[PROJECT].vcxproj" (default target) (2) ->
(ClCompile target) -> d:\src\[PATH]\Bar.h(86,1): error C1010:
unexpected end of file while looking for precompiled header. Did you
forget to add '#include "precomp.h"' to your source?
[D:\src\[PATH2]\[PROJECT].vcxproj]