cpp dev
cpp dev

Reputation: 163

Using precompiled headers, header file changes arent picked up, expected?

Visual Studio C++ lib project Project is set to use precompiled headers stdafx.cpp is set to create precompiled header

I have a header file, MyClass.h If I build, then make a change to MyClass.h that should fail to compile, compile still succeeds. If I do a rebuild, or if I make a change to a cpp file that includes "MyClass.h", then the compile fails as expected.

Is this expected because I'm using precompiled headers? Is there any way to fix it so a 2nds buid picks up header changes without turning off precompiled headers?

Upvotes: 3

Views: 674

Answers (4)

cpp dev
cpp dev

Reputation: 163

In the project properties, set "Enable Minimal Rebuild" to No

Upvotes: 2

Edward Strange
Edward Strange

Reputation: 40897

VisualStudio can often get pretty damn stupid over changes. It can go either way, but usually it goes the way you're running into.

I've had it catch onto changes in a header used by one file, but not the fact that it's used in others. So it compiles the one but not the others. Then I get really weird linker errors.

It could of course still be your own damn fault, but VS is, in fact, notoriously stupid. Sometimes a complete rebuild will fix the issue permanently, until next time. Other times you have somehow hosed the project file and hopefully you can get back to the original (like a source server revert). "Undo" most usually does not undo this kind of fubar.

I've noted this several times not needing to be a header that's in the precompiled header. It seems to be somewhat random but one more common correlation is that the header is full of templates. VS is just plain retarded wrt templates.

Upvotes: 0

Len Holgate
Len Holgate

Reputation: 21644

Are you sure that stdafx.cpp includes the header in question?

Upvotes: 0

Steve Townsend
Steve Townsend

Reputation: 54178

Make sure that the header file you are altering is referenced by your project in Solution Explorer. If this is the case, the full build should trigger when it is changed.

Upvotes: 3

Related Questions