Questions tagged [precompiled-headers]

A precompiled header is a header file that has statically compiled but still separate from its final executable in order to speed up compilation of dependent files.

In C and C++, precompiled headers allow for quicker compilation times by keeping the definitions from a given header in an compiled state. This allows the compiler to quickly incorporate the header when a file dependent on the header is being compiled.

Rather than having to parse through code, precompiled headers allow the compiler to skip directly to a more intermediate state. For headers that are used frequently this can result in significant compile-time savings.

454 questions
4
votes
1 answer

Is including resource.h in precompiled header a good idea?

The VS-IDE will write //{{NO_DEPENDENCIES}} to resource header files. This comment is actually a feature that prevents (unnecessary) rebuilding of cpp files that include the resource header. But, like stated in the MSDN, this can lead to…
4
votes
6 answers

VS2008 win32 project defaults - remove default precompiled headers

I have been through every option to try to find a way to get the IDE to let me create a new win32pject without precompiled headers. I have read every thread on this forum with the words "precpmpiled headers" in it and the closest I got…
Mike Trader
  • 8,564
  • 13
  • 55
  • 66
4
votes
3 answers

Problem with makefile making .gch files instead of.o files

So, I'm making a program to test the efficiency of certain data structures. I have all the .h files and I made a very terrible makefile that probably is wrong, although it seems to work up to a point. Instead of making .o files it makes .gch…
user92949
3
votes
1 answer

Incorrect stack trace with GCC + precompiled header

I'm debugging a project that uses precompiled headers under GDB. While inspecting crash stack trace, I found that GDB prints correct functions names but incorrect file and line number information. Look at the following examples: file.h #ifndef…
Rride.a
  • 51
  • 8
3
votes
2 answers

What's the benefit of including common files in one single header file?

I was looking at the doom3 code on github and I notice something unusual. Several files have only one include for a file called idlib/precompiled.h and this file have includes for several other headers like ... #include #include…
ibrabeicker
  • 1,786
  • 2
  • 19
  • 31
3
votes
2 answers

Pre-compiled header gets created on every make?

I have a very simple makefile, that basically does the following: # Pre-compiled header CORE_PCH_FILENAME =Core.h CORE_PCH: $(CXX) $(CXX_CFLAGS) -x c++-header $(CORE_PCH_FILENAME) #Objects obj/%.o: CORE_PCH %.cpp obj/%.d @mkdir -p…
zedxz
  • 113
  • 1
  • 8
3
votes
3 answers

Processing the precompiled header gives me errors I don’t understand

I am building an iOS 4.2+ game using Xcode 4.1 and Pixelwave, on OS X Lion. At one point during the development, I did a Clean of the project, and ever since I have been unable to compile the project, as I get an enormous number of errors when it…
adurdin
  • 1,376
  • 1
  • 10
  • 15
3
votes
1 answer

-include'ing a precompiled header with g++

I'm trying to include a precompiled header file into my project by adding -include myprecompiledheader.h to my compiler flags. However, when I use the -H option in GCC, this file doesn't show up in the list and thus I can't look at the "!" or "x" to…
rcv
  • 6,078
  • 9
  • 43
  • 63
3
votes
1 answer

Force CMake to rebuild precompiled headers

How do I get CMake to rebuild all the precompiled headers? (Using g++ and Linux) And how do I get CMake to disable all precompiled headers? I am getting some build errors that have sprung up and they refer to the .ch files. So want to investigate…
Captain Jack sparrow
  • 959
  • 1
  • 13
  • 28
3
votes
4 answers

Why are header guards unnecessary in stdafx.h?

I don't understand why header guards are not used in pre-compiled headers... Any ideas?
aCuria
  • 6,935
  • 14
  • 53
  • 89
3
votes
3 answers

Are there cross-platform precompiled header frameworks/methods in C++?

I'm wondering what others have experienced implementing cross-platform (linux and windows) precompiled headers in C++. I'm thinking of what Visual Studio lets you do with stdafx.h files that can drastically improve compile times for large amounts of…
Doug T.
  • 64,223
  • 27
  • 138
  • 202
3
votes
1 answer

How to use multiple precompiled headers; some from a library

I do not think this is unique to my projects, it applies to any C++ library that uses precompiled headers and a project that uses the library that has its own precompiled headers. Its just that C++/winRt headers are SOOO time consuming you really…
Brian Reinhold
  • 2,313
  • 3
  • 27
  • 46
3
votes
1 answer

Clang CMAKE Precompiled headers

I've found a lot of examples on how to use precompiled headers for MSVC, but I can't seem to find any examples using clang. From this SO post I can see the clang commands but I'm wondering how they translate into cmake: Decrease clang compile time…
Braden Edmunds
  • 177
  • 1
  • 7
3
votes
1 answer

Precompiled headers not used by GCC when building with a makefile

I'm trying to use precompiled headers with GCC to speed up the compilation process. If I launch the compilation directly from the command line the precompiled headers are used, but if I try to organize the compilation using a makefile they are…
disquisitiones
  • 167
  • 2
  • 11
3
votes
2 answers

failed to emit precompiled header

Good Afternoon I am trying to implement googles heatmaps into my map based project. In this particular project, I get the following errors when trying to build. failed to emit precompiled header…