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.

405 questions
175
votes
10 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
  • 3,775
  • 8
  • 33
  • 54
134
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,093
  • 2
  • 16
  • 24
106
votes
14 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,061
  • 2
  • 8
  • 3
93
votes
7 answers

Precompiled headers with GCC

Anyone had any success getting 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,440
  • 1
  • 12
  • 10
61
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…
51
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
  • 97,781
  • 45
  • 291
  • 525
48
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
  • 63,560
  • 33
  • 139
  • 197
39
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
  • 59,991
  • 50
  • 166
  • 218
39
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
  • 155,475
  • 189
  • 518
  • 818
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
  • 9,567
  • 17
  • 85
  • 137
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
  • 68,458
  • 72
  • 198
  • 283
32
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
  • 10,753
  • 21
  • 69
  • 83
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,000
  • 20
  • 99
  • 163
26
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…
ralphtheninja
  • 107,622
  • 20
  • 101
  • 118
1
2 3
26 27