precompiled-headers

Every C++ header in a project as a precompiled header

ぃ、小莉子 提交于 2021-02-10 13:38:32
问题 The usual approach is to have one precompiled header in a project that contains the most common includes. The problem is, that it is either too small or two big. When it is too small, it doesn't cover all the used headers so these have to be processed over and over in every module. When it is too large, it slows down the compilation too much for two reasons: The project needs to be recompiled too often when you change something in header contained in the precompiled header. The precompiled

Every C++ header in a project as a precompiled header

点点圈 提交于 2021-02-10 13:38:19
问题 The usual approach is to have one precompiled header in a project that contains the most common includes. The problem is, that it is either too small or two big. When it is too small, it doesn't cover all the used headers so these have to be processed over and over in every module. When it is too large, it slows down the compilation too much for two reasons: The project needs to be recompiled too often when you change something in header contained in the precompiled header. The precompiled

Collect common includes in a single file - good practice?

自闭症网瘾萝莉.ら 提交于 2021-02-07 12:46:13
问题 I am trying to learn how to deal with a lot of includes, and still keep my code tidy. I am programming a Qt application and I have put files commonly used (and that doesn't change) in a file called "Util.h". Util.h #pragma once #include <Core/IObserver.h> #include <Core/Math.h> #include <QAction> #include <QDockWidget.h> #include <QFileDialog> #include <QGraphicsBlurEffect> #include <QLabel.h> #include <QMainWindow.h> #include <QMenu.h> #include <QMessageBox.h> #include <QShortcut.h> #include

C3859: Virtual memory range for PCH exceeded

♀尐吖头ヾ 提交于 2021-01-21 07:25:56
问题 I get this error message from time to time (not every time) I compile (EDIT: sorry, I didn't make myself clear here: I actually meant "rebuild") my mixed-mode project. And Visual Studio tells me to "recompile with a command line option of '-Zm114' or greater". In principle no problem, I just do as VS tells me. But currently, there are two problems with this: Why does it not occur every time I do a rebuild? If I understand correctly, the compiler ran out of memory while compiling my project.

C++ Do I have to include standard libraries for every source file?

↘锁芯ラ 提交于 2020-02-01 02:53:48
问题 I'm a bit confused at the moment because I'm planning to include multiple source and header files for the first time in one of my projects. So I'm wondering if this would be the right approach? Do I have to include the string header in every source file that uses it directly? And what about the "stdafx.hpp" header that Visual C++ wants me to include? Would that be the way to go? main.cpp #include "stdafx.hpp" #include <string> //? #include <stringLib1.h> #include <stringLib2.h> using std:

Should re-include stuff thats already in the project scope precompiled header?

落爺英雄遲暮 提交于 2020-01-25 00:30:06
问题 I have a precompiled header stdafx.h which is used in all source files in my project. Thus all headers in the stdafx.h are available in all code files in the project. What I'm unsure about is whether or not to re-include stuff thats already in the precompiled header. What do you guys think? e.g. stdafx.h #pragma once #include <memory> my_class.h #pragma once #include <memory> // Re-include or not that's the question. Best practice? struct my_class { }; typedef std::shared_ptr<my_class> my

Advantages of removing includes which are already in precompiled header?

巧了我就是萌 提交于 2020-01-17 03:14:07
问题 I'm aware of disadvantages, but is there an improvement in compile time when you clean your sources from #include statements which are already in precompiled header? I understand that header guards (be it #pragma once or #ifdef guards) will ensure that headers which are redundant will be quickly skipped, but is there a slowdown when accessing the header file and checking for the guard? I'm working on quite big project and even minor speedups in small scale could help in big scale. 回答1: In my

Visual C++ Precompiled Headers errors

邮差的信 提交于 2020-01-12 04:30:40
问题 Update: What are the effects of including stdafx.h in my header files? I started on a C++ project in Linux/Eclipse CDT and imported it into Visual C++/Windows. In Visual C++, I started using precompiled headers to speed up compilation and defined stdafx.cpp and stdafx.h. Here's my stdafx.h #pragma once #include <string> #include <vector> #include <map> ... and my stdafx.cpp #include "stdafx.h" In every .h and .cpp file, I have the following: #pragma once //if in a header file #include "stdafx