precompiled-headers

Why do I need to include the precompiled header in all the files in C++?

只愿长相守 提交于 2019-12-06 16:32:56
If I don't include the stdafx even in an empty .cpp, I get this error fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source? Why do I need to include it even in dummy files? If you use them, then you must include them. But you can turn them off in the project properties. However, the recommended way to use them is to "Force Include" the PCH from the command line , so that the file itself doesn't contain the PCH. That way the source file can be compatible with other systems. You can disable precompiled headers

Speed up compilation/link time when using boost libraries

雨燕双飞 提交于 2019-12-05 13:05:26
问题 I'm using Boost Program Options, and it takes quite a while (10 seconds or even more) for compiling very small C++ code with it. It took 1 second compiling the code without boost library. Any idea how to boost compilation/link time with boost library? It's cross platform, so I need to compile the code with Mac OS X/Linux/PC. 回答1: There isn't really much you can do beyond the usual tricks: minimize dependencies: pull in only the Boost headers you really need, and use as specific headers as

How do I add a precompiled header file to my ios project?

社会主义新天地 提交于 2019-12-05 10:46:19
问题 I'm looking to create a precompiled header file, to avoid having to include the same debug and tracking libraries in every header in the project. I've created a file called -Prefix.pch: #ifdef __OBJC__ #import "Blah.h" #import "Blarg.h" #endif and added it to the project. Is there anything more I'm supposed to do, or should things just work now (assuming I do a project clean and recompile)? 回答1: Set the target's build settings as follows: GCC_PRECOMPILE_PREFIX_HEADER=YES GCC_PREFIX_HEADER=

Objective-C typedef enum in global constants file

房东的猫 提交于 2019-12-05 05:25:27
OK, this is related to question "Constants in Objective C" . I created Constants.h and its corresponding Constants.m file: // Constants.h extern int const BOOKS; typedef enum SSDifficultyLevel { EASY = 0, MEDIUM = 1, HARD = 2 } SSDifficultyLevel; // Constants.m int const BOOKS = 66; My question: Is OK for the enum to be typedef 'd in Constants.h ? The code is compiling fine (no warnings or errors so far) but I was wondering if this is the right way to do it, as the solution provided in the related question involves splitting the constant's definition and declaration. Thanks. well, a constant

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

家住魔仙堡 提交于 2019-12-05 02:09:16
问题 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. Even stranger still is that it only happens on one project. In the SConscript file for this project, I have the following to compile the PCH on windows: if env['PLATFORM'] == 'win32': env['PCH'] = env.PCH('MyPCH-LSCommon.pch', 'Common/src/MyPCH.h')[0

cc1plus.exe crash when using large precompiled header file

眉间皱痕 提交于 2019-12-05 01:42:22
I'm having an issue using precompiled header files with MinGW. The compiler seems to find the precompiled header file but cc1plus.exe crashes immediately after (cc1plus.exe has stopped working). I've understood that this might be in connection with cc1plus.exe's low stack size, so I did the following to increase it: editbin cc1plus.exe /STACK 33554432 and I also tried to no avail: editbin cc1plus.exe /STACK 32768k This however did not solve it as it still keeps crashing whenever I try to compile my application. By the way I'm using the latest MinGw (gcc v 4.6.2) and the latest Eclipse CDT if

Precompiled Headers? Do we really need them

主宰稳场 提交于 2019-12-04 10:27:34
问题 Back a long time ago I used to use pre-compiled headers: a. to speed compilation and b. because I supported multiple development tools like CodeWarrior, MPW, VS, ProjectBuilder, gcc, intel compilers, etc, etc. Now I have a Mac Pro with 32gb of RAM. Now I use just CMake. So do we really need pre-compiled headers any more? Are there obvious benefits that I just dont see/know? How can one make a cross-platform pre-compiled header? Maybe that would simplify my life too. 回答1: There is no such

gcc precompiled headers weird behaviour with -c option

两盒软妹~` 提交于 2019-12-04 09:44:23
问题 Short story: I can't make precompiled headers work properly with gcc -c option. Long story: Folks, I'm using gcc-4.4.1 on Linux and before trying precompiled headers in a really large project I decided to test them on simple program. They "kinda work" but I'm not happy with results and I'm sure there is something wrong about my setup. First of all, I wrote a simple program(main.cpp) to test if they work at all: #include <boost/bind.hpp> #include <boost/function.hpp> #include <boost/type

Speed up compilation/link time when using boost libraries

安稳与你 提交于 2019-12-04 00:38:50
I'm using Boost Program Options , and it takes quite a while (10 seconds or even more) for compiling very small C++ code with it. It took 1 second compiling the code without boost library. Any idea how to boost compilation/link time with boost library? It's cross platform, so I need to compile the code with Mac OS X/Linux/PC. jalf There isn't really much you can do beyond the usual tricks: minimize dependencies: pull in only the Boost headers you really need, and use as specific headers as possible (many libraries have a single "master" header, such as boost/thread.hpp , but also a

How do I add a precompiled header file to my ios project?

孤者浪人 提交于 2019-12-03 22:49:01
I'm looking to create a precompiled header file, to avoid having to include the same debug and tracking libraries in every header in the project. I've created a file called -Prefix.pch: #ifdef __OBJC__ #import "Blah.h" #import "Blarg.h" #endif and added it to the project. Is there anything more I'm supposed to do, or should things just work now (assuming I do a project clean and recompile)? Set the target's build settings as follows: GCC_PRECOMPILE_PREFIX_HEADER=YES GCC_PREFIX_HEADER="Prefix.pch" Note that you can plop these keys in the Build Settings search field, if you prefer to use Xcode's