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

Precompiling Eigen Headers

I am building a C++ project using Eclipse on Windows OS, I am also using the Eigen Linear Algebra library. My problem is with the very slow compiling time of Eigen (about 50 sec). I've tried these proposed solutions: Precompiled headers in…
M.A.
  • 169
  • 1
  • 1
  • 18
5
votes
3 answers

Pre-Compiled Header Design Question

I have code that uses a pre-compiled header. (previously done by someone else) In it, they are including several .h files. If I have classes that use common .h files that are not currently in the existing pre-compiled header, would tossing them in…
ML.
  • 195
  • 1
  • 1
  • 8
5
votes
1 answer

Including a Header in Pre Compiled Header AND Outside of it in my Class Header File

I have searched for a while on this, but I keep getting answers that do not answer this specific scenario. I have a class called VisibleGameObject. I am wondering what happens if I put my normal includes in the header (so that other developers can…
Mr_Moneybags
  • 3,927
  • 3
  • 19
  • 15
5
votes
1 answer

Question about precompiled headers in Visual C++

If I put a header (a.h) into stdafx.h and that header includes another header (b.h) that is not mentioned in stdafx.h, will b.h be visited every time someone includes a.h or is it compiled in as part of a.h? If it is compiled into a.h, what happens…
Dave
  • 885
  • 2
  • 10
  • 20
5
votes
3 answers

Visual studio forces to include precompiled header file in all compilation units of the project?

When compiler compiles source (e.g. *.cpp) file, it creates object file (e.g. *.o), so that later it will be linked to other .o and .so (.lib files for Windows) files and will constitute the executable file. Now for analogical situation for not…
Narek
  • 38,779
  • 79
  • 233
  • 389
4
votes
2 answers

SCons, Boost::ASIO, Windows Precompiled Headers, and Linker Errors

I'm investigating using SCons for our build process as we develop C++ for multiple platforms. I'm 99% of the way there in the build configuration, but I'm running into a VERY strange error on Windows having to do with the precompiled header file. …
Grant Limberg
  • 20,913
  • 11
  • 63
  • 84
4
votes
3 answers

precompiled header files usage for library builders

According to this answer boost and STL headers belong into the precompiled header file (stdafx.h in the MSVC world). So I changed the headers of my dynamic link library project and moved all STL/Boost headers into the stdafx.h of my…
nabulke
  • 11,025
  • 13
  • 65
  • 114
4
votes
1 answer

c++ precompiled headers vs. modules

I'm confused on the difference between precompiled headers and modules. What advantage does one have over the other? I've read the Microsoft documentation on both of them but it hasn't helped me much. Precompiled headers Modules
4
votes
1 answer

CMake precompiled headers issue with mixed C/C++ project

Environment cmake version 3.21.1 running on macOS 10.15.7, clang version string Apple clang version 12.0.0 (clang-1200.0.32.29). Introduction I have a project for a library written in C, however its unit tests are written in C++ using Google Test.…
swineone
  • 2,296
  • 1
  • 18
  • 32
4
votes
1 answer

Can't include standard libs in cmake_pch.h

I am trying to generate a precompiled header in cmake that contains my regularly used standard libs. When I run cmake there is no errors but when I build it says it can't find the headers in cmake_pch.h. Here is the snippet of my cmake script that…
4
votes
0 answers

Avoiding implicit precompiled header dependencies?

We are using a precompiled header to include library files such as Boost and Windows. Our precompiled.h is included explicitly at the top of each .cpp file in order to work with the precompiled header commands (/Yc, /Yu, and /Fp). I accepted that…
mskfisher
  • 3,291
  • 4
  • 35
  • 48
4
votes
3 answers

Precompiled header and Visual Studio

Is there a way to set Visual Studio solution parameters so it just create precompiled headers without building whole solution. Specifically, it is a huge c++ solution with many projects in itself. Thank you.
Mujo Osmanovic
  • 931
  • 2
  • 11
  • 15
4
votes
2 answers

Xcode 4 gcc failure on Archive build: skips precompile step?

I have been able to Archive on Xcode 4 successfully, but all of a sudden (??), I can't. The build fails with an invalid .pch file. The error is pasted in below (got from a reattempt with -Winvalid-pch, but what seems to be happening from the build…
Ben Zotto
  • 70,108
  • 23
  • 141
  • 204
4
votes
1 answer

Precompiled headers in VisualStudio Cross Platform (Linux) project

In a regular VisualStudio project you can setup the precompiled header by going to Configuration Properties -> C/C++ -> Precompiled Headers. However, when dealing with a Cross Platform (Linux) project, the Precompiled Header option is missing. Is…
Gediminas
  • 1,830
  • 3
  • 27
  • 47
4
votes
1 answer

Precompiled headers - necessary to remove all precompiled headers from all other files

I have a very big project and for the sake of compilation speed I started to test precompiled headers. I've setup everything now: enable precompiled headers in VS (use them for the project, create it for the StdAfx.honly) use multi processor…
prom85
  • 16,896
  • 17
  • 122
  • 242