What is a .h.gch file?

后端 未结 5 1708
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 11:51

I recently had a class project where I had to make a program with G++.

I used a makefile and for some reason it occasionally left a .h.gch file behind.

So

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 12:32

    Other answers are completely accurate with regard to what a gch file is. However, context (in this case, a beginner using g++) is everything. In this context, there are two rules:

    1. Never, ever, ever put a .h file on a g++ compile line. Only .cpp files. If a .h file is ever compiled accidentally, remove any *.gch files

    2. Never, ever, ever put a .cpp file in an #include statement.

    If rule one is broken, at some point the problem described in the question will occur. If rule two is broken, at some point the linker will complain about multiply-defined symbols.

提交回复
热议问题