How to make GCC not generate .h.gch files

前端 未结 2 1588
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 07:50

Using GCC to compile C code, GCC automatically generate .h.gch files.

Question

How do I suppress this?

2条回答
  •  一生所求
    2021-02-09 08:15

    I came here looking for an answer to the same problem. I found an answer at another website. If you add the -fsyntax-only option to the compile line, no output files are generated.

    gcc -fsyntax-only myheader.h
    

    I purposefully compile .h files I'm working on to check for syntax errors. In this case generation of the .gch file is quite annoying since if the .h file is subsequently modified, and you don't recompile it (to generate a new .gch), then the old .gch file hides the newer .h file for subsequent .c/.cpp compilations (which can really be quite confusing...)

    Now I guess you could write a dummy .c/.cpp file to include a new header that you've just written, and then compile that to test it out, but I'm way too lazy for such nonsense. The -fsyntax-only appears to be a much nicer solution.

提交回复
热议问题