Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a .h.gch file?

Tags:

c++

g++

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?

like image 819
mnuzzo Avatar asked Aug 06 '09 20:08

mnuzzo


People also ask

What is precompiled header C++?

In computer programming, a precompiled header (PCH) is a (C or C++) header file that is compiled into an intermediate form that is faster to process for the compiler.


2 Answers

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 pre-compiled headers it will make them if they don’t exist and use them in the next build.

Sometimes the *.h.gch will get corrupted or contain outdated information, so deleting that file and compiling it again should fix it.

like image 129
Dunewalker Avatar answered Oct 11 '22 17:10

Dunewalker


If you want to know about a file, simply type on terminal

file filename 

file a.h.gch gives:

GCC precompiled header (version 013) for C 
like image 45
riteshkasat Avatar answered Oct 11 '22 17:10

riteshkasat