"Bo Peng" <[EMAIL PROTECTED]> writes: | > some sourcefiles will get includes | > they strictly speaking did not need. | | That is what I meant. our pch.h contains headers that are not commonly | used. (and in pch mode, they are included.)
Then they should be regenerated/reviewed. | > | In pch mode, | > | --include=pch.h is passed. This will *not* work with msvc since msvc | > | scans source file for a stopping header file like stdafx.h. (Of | > | course, bugger off msvc) | > | > What is a 'stopping header file'? | | For example, in a typical ms c++ file, it has | | #include <stdafx.h> | #cinldue <others.h> | | stdafx.h contains all commonly used headers. msvc knows from a | compiler flag (or by default) that stdafx.h (stopping header) is | pre-processed and skip it. Use #pragma hdrstop instead. | | > | > | > | 2. pch.cpp with | > | > | #include <pch.h> | > | > why? | > | | | > I don't quite understand what the pch.cpp file is needed for at all... | | Gcc has that -cxx-header (?) option that generate pch from a pch.h | file, but msvc needs a source file to do that. If you have functions | that will be called by all others, they can be put into pch.cpp as | well (to be precompiled). That is why we need an empty (#include | <pch.h> only) pch.cpp. I understand... so a pch.cpp that is only used for win only needs to contain: #include "pch.h" #pragma hdrstop pch.pch And then we only need to add /Fp compiler option pointing at pch.pch. I need good examples to understand this properly. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_PREDIR_hdrstop.asp Then we can by adding a pch.cpp, avoid adding #include "pch.hpp" to all files.... but are msvc clever enough to avoid duplicate reading of include files that exists both in pch.hpp and in file.hpp? -- Lgb