-include'ing a precompiled header with g++
I'm trying to include a precompiled header file into my project by adding -include myprecompiledheader.h
to my compiler flags. However, when I use the -H option in GCC, this file doesn't show up in the list and thus I can't look at the "!" or "x" to determine if my .pch file is being used or not. Is there some way to tell if my precompiled header is being used when I -inc开发者_StackOverflow社区lude
it?
You can use a dummy header which contains only an #error directive, and put that in the same place as the .gch file. For example:
project/precompiled.h // your precompiled header
project/pre.h.gch // precompiled.h compiled into a gch
project/pre.h // contains only "#error "Not using the GCH."
Then, when you -include pre.h
, if the compiler doesn't use the gch file it'll throw an error.
精彩评论