0

I have two headers world.h worldw.h.

world.h

void h_world();

worldw.h

void g_world();

After precompilation with gcc world.h and gcc worldw.h I have world.h.gch and worldw.h.gch. Futher I'm adding this precompiled headers to main.c:

#include "world.h.gch"
#include "worldw.h.gch"
....

But when I'm compiling this I have more than thousand errors. I'm expected that it's ok, because precompiled header is just reduce a compile time.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • possible duplicate of [Precompiled headers with GCC](http://stackoverflow.com/questions/58841/precompiled-headers-with-gcc) – Retired Ninja Jan 02 '14 at 02:49

1 Answers1

1

Instead of

#include "world.h.gch"
#include "worldw.h.gch"

you need

#include "allworld.h"

And in allworld.h put

#include "world.h"
#include "worldw.h"

Then precompile allworld.h ... if a .h.gch file exists, the compiler will use it; if not, it will use the .h file. You can see what is being used by compiling your source with the -H flag.

There are a number of restrictions for using a precompiled header; see http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Jim Balter
  • 16,163
  • 3
  • 43
  • 66