开发者

-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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜