Click to See Complete Forum and Search --> : Precompiled header woes


John E
September 12th, 2002, 12:50 PM
I've long been hugely suspicious of precompiled headers and always turn them off whenever possible. The biggest problem is that if you modify a header file, the compiler doesn't seem to rebuild the pch. Therefore any code you want to recompile simply carries on using the unmodified version of the header code. This doesn't seem to be confined to Visual C++. Other compilers seem to behave in the same way.

Firstly, is there any way to force a precompiled header to be rebuilt when a relevant header file changes?

Secondly, when you select precompiled headers in the project settings, what exactly is the meaning of the field called "through header". EG some sample programs that I've seen are designed to use precompiled headers "through header stdafx.h". What exactly does this mean??

Thanks,

John E

Graham
September 12th, 2002, 03:51 PM
I've never had that problem - but then, I try to avoid putting changeable headers in stdafx.h. In fact, my philosophy is to not touch stdafx.h after Visual Studio has created it (unless it's to add in a non-default MFC header).

Secondly, when you select precompiled headers in the project settings, what exactly is the meaning of the field called "through header". EG some sample programs that I've seen are designed to use precompiled headers "through header stdafx.h". What exactly does this mean??

It means that the compiler basically ignores everything until it sees '#include "stdafx.h"'. This has been the cause of a number of problems for novices who put code above that line and then can't figure out why they get errors.