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
3
votes
1 answer

How to precompile headers when building target in single step?

I have a simple makefile which finds the CPP files relative to it and builds the target from there. How could I modify this to also precompile the header files relative to it when building the target? TARGET ?= application CXXFLAGS += -Os -I. -MMD…
Josh Olson
  • 397
  • 2
  • 15
3
votes
3 answers

Precompiled headers: do's and don'ts?

I know precompiled headers are used for speeding up compilations, but are there any do's and don'ts to what files I should include in them? For example, I have a project that uses a lot of boost libs so I just include the boost header files in…
Marlon
  • 19,924
  • 12
  • 70
  • 101
3
votes
2 answers

Can force include be used with pre-compiled headers in Visual C++?

If /Yu is set for an individual cpp file (i.e. not for an entire project) is it possible to set /FI to specify the header file to be included or must the header file be included with for example #include "stdafx.h" if /Yu"stdafx.h" is passed to…
Johnny Haddock
  • 415
  • 3
  • 11
3
votes
2 answers

GCC - Multiple precompiled headers and specific paths

Background I have a large Makefile project I'm working on which I'd like to tidy up a bit. It builds several dozen sub-projects, each of which contains roughly 100 .cpp and .h files. I've set it up so that it's able to build debug and release…
Cloud
  • 18,753
  • 15
  • 79
  • 153
3
votes
1 answer

Macros in iOS to give warning if method used is not available on minimum supported version

Recently I updated my Xcode to 6.3(sdk iOS8). I am using one API of NSString called "containsString" which is available from iOS 8.0 onwards. But my deployment target is 7.0 and this API is not available on iOS7. App is running fine on iOS8, however…
Aditya Gaonkar
  • 660
  • 6
  • 13
3
votes
1 answer

GCC fails with no message when using precompiled headers

I am trying to use precompiled headers in my rather large android NDK project. The precompiled header builds correctly, and I get the gch file that I can see is being used when I compile the source file. However, the "make" command fails with Error…
styill
  • 51
  • 4
3
votes
2 answers

Can Precompiled Headers Be Used Like Libraries?

Is it possible to use Precompiled Headers like a library is used? For example can I create a header containing preprocessor like so: #include #include #include "boost_headers.hpp" Compile it into a PCH and then distribute the…
Soapy
  • 557
  • 14
  • 29
3
votes
1 answer

ERROR: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

I am developing an app for iPhone and iPad. Suddenly I can't run my project because of this error: clang: error: no such file or directory: '/Users/AkdemiaMacBookAir/Developer/iOS/ios-akdemia/ios-akdemia/ios-akdemia-Prefix.pch' clang: error: no…
origds
  • 1,047
  • 2
  • 11
  • 25
3
votes
1 answer

Precompiled Header and MSBuild

I have a precompiled header that needs to be included atop each .cpp in my project. I fear that I will waste a lot of time explaining and fixing that in coworkers code. Is there an MSBuild step that I can do to #include "stdafx.h" at the top of all…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
2 answers

C++ - Precompiled headers issue

Okay so I am writing something up in C++ and last night it was fine, I could compile perfectly w/o a problem. I saved all of my stuff and closed VS 2010 Ultimate. This morning when I went to go work on my stuff I tried recompiling and I got just…
Joshe343
  • 65
  • 1
  • 10
3
votes
1 answer

Prefix.pch with Modules Enabled?

If I have "Enable Modules (C and Objective-C)" set to "Yes" in Build Settings, shouldn't I get rid of the Prefix.pch precompiled header file? If not, what are the reasons I should keep it?
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
3
votes
2 answers

XCode cannot find #define macro in *prefix.pch but compiles OK

I've added something in -prefix.pch file, but XCode gives me error when I use it, saying Use of undefined identifier ... However if I compile it (Command+B), it compiles, so I thought it was caused by derived data, I then tried to remove derived…
hzxu
  • 5,753
  • 11
  • 60
  • 95
3
votes
1 answer

What's the difference when putting header inside pch file?

In some tutorial, it is said that we can put some header files in the pch file. After that, I still see that the same header are included in the individual header file? why we put the header in the pch file? For exmaple, UIKit.h
Adam Lee
  • 24,710
  • 51
  • 156
  • 236
3
votes
2 answers

Precompiled header file for shared library project using GCC

I am trying to create a precompiled header file for my shared library using GCC. After making the necessary configuration and trying to build, I got these warnings: cc1plus: warning: ./PrecompiledHeaders.h.gch/.c++: created and used with different…
Rafid
  • 18,991
  • 23
  • 72
  • 108
3
votes
1 answer

Gyp precompiled headers for xcode

How do you specify precompiled headers for xcode with gyp, specifically xcode 4.6 with clang. I only see visual studio options. 'msvs_precompiled_header': 'stdio.h', 'msvs_precompiled_source': 'precomp.c',
Michael Marcin
  • 686
  • 6
  • 17