tags:

views:

2195

answers:

3

I have a question. 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. Sometimes, this didn't affect the compilation, but every so often it would result in the compiler issuing an error for an issue which had been fixed or which did not make sense. I have two questions:

1) What is a .h.gch file and what is one used for? and

2) Why would it cause such problems when it wasn't cleaned up?

Thanks for the help.

+6  A: 

Its a GCC precompiled header.

Wikipedia has a half decent explanation, here

Goz
+3  A: 

a) They're precompiled headers: http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

b) They contain "cached" information from .h files and should be updated every time you change respective .h file. If it doesn't happen - you have wrong dependencies set in your project

gonzo
+4  A: 

A '.gch' file is a precompiled header.

if a '.gch' is not found then the normal header files will be used.

However, if your project is set to generate precompiled headers it will make them if they don’t exist and use them in the next build.

Sometimes the *.h.gch will get currupted or contain outdate information, so deleteing that file and compiling it again should fix it.

Dunewalker