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
192
votes
14 answers

How to fix .pch file missing on build?

When I build my c++ solution in Visual Studio it complains that the xxxxx.pch file is missing. Is there a setting I am missing to get the pre-compiled headers back? here is the exact error for completeness: Error 1 fatal error C1083: Cannot open…
Sam Mackrill
  • 4,004
  • 8
  • 35
  • 55
135
votes
22 answers

How to fix PCH error?

When I try to build my app in Xcode, I get this error message: PCH file built from a different branch ((clang-425.0.24)) than the compiler ((clang-425.0.27)) It doesn't happen before, but this was the first build after updating Xcode. Other apps…
Macro206
  • 2,143
  • 3
  • 19
  • 25
120
votes
12 answers

Using pre-compiled headers with CMake

I have seen a few (old) posts on the 'net about hacking together some support for pre-compiled headers in CMake. They all seem a bit all-over the place and everyone has their own way of doing it. What is the best way of doing it currently?
Glutinous
  • 1,201
  • 2
  • 9
  • 3
105
votes
7 answers

Precompiled headers with GCC

How can I get precompiled headers working with GCC? I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on Cygwin GCC 3.4.4 and using 4.0 on Ubuntu.
Lee Baldwin
  • 1,560
  • 2
  • 12
  • 10
67
votes
7 answers

Unexpected end of file error

I hope you can help me, cause I have no idea about what's going on. I'm having the following error while trying to add Beecrypt library to my project: fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to…
52
votes
5 answers

Why use precompiled headers (C/C++)?

Why use precompiled headers? Reading the responses, I suspect what I've been doing with them is kind of stupid: #pragma once // Defines used for production versions #ifndef PRODUCTION #define eMsg(x) (x) // Show error messages #define…
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
49
votes
1 answer

Compile C files in C++ project which do not use precompiled header?

Can I disable precompile header for .c files in my C++ project? I'm getting these errors when I want to add the .C files to my program for a scripting virtual/abstract machine which is in C: Error 1 error C1853: 'Release\pluginsa.pch' precompiled…
user1182183
42
votes
6 answers

Sharing precompiled headers between projects in Visual Studio

I have a solution with many Visual C++ projects, all using PCH, but some have particular compiler switches turned on for project-specific needs. Most of these projects share the same set of headers in their respective stdafx.h (STL, boost, etc). I'm…
Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
41
votes
2 answers

Is it OK to remove Prefix.pch file from the Xcode project?

The Xcode project generates Prefix.pch file automatically. When I deleted this file and tried to build, I got build error saying '*_Prefix.pch' file is missing. Is Prefix.pch file is a must for compiling with Xcode? How can I build without the…
prosseek
  • 182,215
  • 215
  • 566
  • 871
40
votes
4 answers

What to put in precompiled header? (MSVC)

What are the best candidates for a precompiled header file? Can I put STL and Boost headers there, even though they have templates? And will that reduce compile times? Also, what are the best IDE settings to reduce compile times?
rlbond
  • 65,341
  • 56
  • 178
  • 228
39
votes
4 answers

Purpose of stdafx.h

What is the purpose of the file stdafx.h and what is meant by precompiled headers?
ckv
  • 10,539
  • 20
  • 100
  • 144
33
votes
6 answers

stdafx.h: When do I need it?

I see so much code including stdafx.h. Say, I do not want pre-compiled headers. And I will include all the required system headers myself manually. In that case is there any other good reason I should be aware of where I require stdafx.h?
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
33
votes
3 answers

Precompiled Headers

I have a sample project (not mine) which is in Visual C++ 6. I'm trying to convert it to Visual Studio 2008. The older project is using precompiled headers. Now the questions are: What are precompiled headers? Since the older project is using…
akif
  • 12,034
  • 24
  • 73
  • 85
28
votes
6 answers

xCode 4.4 does not get all the .pch file headers imports?

This is my .pch file - // // Prefix header for all source files of the 'English Club' target in the 'English Club' project // #import #ifndef __IPHONE_4_0 #warning "This project uses features only available in iOS SDK 4.0 and…
shannoga
  • 19,649
  • 20
  • 104
  • 169
27
votes
3 answers

error C1854: cannot overwrite information formed during creation of the precompiled header in object file

foo.cpp(33918) : fatal error C1854: cannot overwrite information formed during creation of the precompiled header in object file: 'c:\somepath\foo.obj' Consulting MSDN about this gives me the following information: You specified the /Yu (use…
rtn
  • 127,556
  • 20
  • 111
  • 121
1
2 3
30 31