Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make GCC not generate .h.gch files

Tags:

c

gcc

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

Question

How do I suppress this?

like image 943
SomeNorwegianGuy Avatar asked Apr 06 '15 02:04

SomeNorwegianGuy


People also ask

What are H GCH files?

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.

Does GCC need header files?

GCC needs to install corrected versions of some system header files. This is because most target systems have some header files that won't work with GCC unless they are changed. Some have bugs, some are incompatible with ISO C, and some depend on special features of other compilers.

What is GCH in C?

File created for program development applications such as GNU project C and C++ compiler (GCC) and Microsoft Visual C++; contains a precompiled header . H file in order to reduce the processing time for compilers; similar to precompiled header .

Do .h files need to be compiled?

You don't need to compile header files. It doesn't actually do anything, so there's no point in trying to run it. However, it is a great way to check for typos and mistakes and bugs, so it'll be easier later.


1 Answers

Files ending in .gch are precompiled headers - header files which have been pre-compiled in order to reduce compilation time when you (re)compile your main program.

They are produced if you invoke the compiler with the header file itself as the target, ie:

gcc myheader.h

Normally you would only be calling the compiler with .c files as targets.

If you don't want it to produce precompiled headers then don't invoke the compiler with the header files as the target.

If you are not deliberately calling the compiler with the headers as targets, you might be using a makefile which is setup to produce these files - it will have rules in it to produce .gch files from .h files. You will need to remove these rules and adjust other rules not to depend on them.

like image 93
harmic Avatar answered Oct 17 '22 04:10

harmic