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
0
votes
0 answers

Using precompiled header in a project that's already using header-only libraries?

I'm building a project and I wanted to make a precompiled header to boost performance. The issue is that I'm also using stbi_image headers in my project, which means I would have to include my header on all the stbi files in my project AND make sure…
Julk
  • 169
  • 7
0
votes
1 answer

Why does make update precompiled headers sometimes, but not always?

THE FILES foo.hpp #include class foo { public: foo(int = 1); int get_x() const { return x; } private: int x; }; foo.cpp #include "foo.hpp" foo::foo(int xp) { x = xp; } main.cpp #include "foo.hpp" int main() { foo…
0
votes
1 answer

Use gsl on Mac 10.6.3

I recently have a project using GSL. After I installed the GSL package on Mac 10.6.3. I cannot compile my code. The gsl lib is located at /usr/local/lib, and the head file located at /usr/local/. When I compile my code I get the the following…
Joe SHI
  • 1,734
  • 4
  • 20
  • 39
0
votes
1 answer

Custom precompiled headers causing compile errors

I am trying to introduce precompiled headers into my project because of long compile times in my project right now. I have a main project that includes a main function and all the real code is in the DLL project(they are linked together.) I named my…
0
votes
1 answer

How to use pre-compiled header on VC++19?

Hello after I've upgraded visual studio to 19 now if I create a C++ project it works fine but I cannot set using "pre-compiled headers" on the beginning of creating project like in visual studio 2015. If I create a project then maybe I should do…
Maestro
  • 2,512
  • 9
  • 24
0
votes
1 answer

How does VS Intellisense find definitions from stdafx.h while editing a header file?

This is an annoying hole in my knowledge and I can't seem to find an answer. I understand why it works during compilation (the header is never compiled in isolation, so stdafx.h will have already been included), but not why it works while…
Kemp
  • 3,467
  • 1
  • 18
  • 27
0
votes
2 answers

Precompiled header for moc_* in Visual Studio with Qt add-in

I try to make moc.exe to add a precompiled header include into generated moc_* files in Visual Studio with Qt plugin. I tried to add a PRECOMPILED_HEADER=myheader.h (also with quotes) line into project's preprocessor definitions, that didn't work. I…
Emil Kabirov
  • 559
  • 4
  • 14
0
votes
0 answers

How to know the files that are the most included in a project?

I am trying to fasten the build by using precompiled headers. I wonder what is the easiest/fastest way to know which files I should include in my "stdafx.h" so that they only build once? Right now, I iterate over every file, and collect the…
Sandra K
  • 1,209
  • 1
  • 10
  • 21
0
votes
0 answers

How to fix "no matching function for call to 'wprintf'" in libclang on windows' visual studio 2015

I'm using libclang to analyse code, because my project has too many files, so I need clang's precompiled headers to speed up. First I save the pch file in disk, but when using it, libclang give errors. const char* custom_args[] = { …
Roland Yim
  • 36
  • 6
0
votes
1 answer

Certain C++ header breaks build when put in Xcode prefix/precompiled header

I'm trying to #include header into Prefix.pch with Xcode precompiled header turned on. However, this breaks the build with error `atomic` file not found. , which is caused by #include in the offending spdlog.h header. My…
kakyo
  • 10,460
  • 14
  • 76
  • 140
0
votes
0 answers

How to use precompiled header in DLL with dependencies

My situation: I'm writing DLL, it has many classes, but I export only one: #pragma once #ifdef APIDLL_EXPORTS #define APIDLL_API __declspec(dllexport) #else #define APIDLL_API __declspec(dllimport) #endif class Process; // <-- ApiClient uses…
colorgreen
  • 265
  • 1
  • 2
  • 12
0
votes
0 answers

Visual Studio precompiled header prevents compiler from recognizing std::cout

I'm trying to build a DLL (but it works the same for static library) in Visual Studio 2017; this is my complete source.cpp file. #include #include "stdafx.h" void f() { std::cout << "I'm in f!\n"; } When I compile, it complains that…
Topological Sort
  • 2,733
  • 2
  • 27
  • 54
0
votes
1 answer

Disable pregenerated headers (PCH) for IntelliSense in VisualStudio for a Linux Makefile project

I am currently working on a Linux Makefile project in VS2017. And in for every header file I get this error: Intellisense PCH Warning: Header stop not at file scope. An intellisense PCH file was not generated Doesn't matter if I have #pragma once…
0
votes
0 answers

stdafx.h does not exist in new New Project Wizard (VS)

cannot open source file stdafx.h or Yes I understand what precompiled headers are I have been struggling the past hour trying to get a precompiled header stdafx.h to my project as I'm getting the error: "cannot open source file…
0
votes
0 answers

Usage of c++17 precompiled headers in an older g++-environment

X-problem: Generating a library out of a cpp-headerfile. Y-problem: Is it possible to make c++17-features available in a non-c++17 environment? I've tried this via a precompiled header-file: $ g++-8 -c ../header.hpp -std=c++17 -fconcepts This…
user1511417
  • 1,880
  • 3
  • 20
  • 41