precompiled-headers

How to implement precompiled headers into your project

丶灬走出姿态 提交于 2019-12-02 14:42:14
I understand the purpose and reasoning behind precompiled headers. However, what are the rules when implementing them? From my understanding, it goes something like this: Set your project up to use precompiled headers with the YU directive. Create your stdafx.h file and set that to be your precompiled header. Include this as the top include statement in each of your .h files. It this correct? Should you exclude the including it in the files that are included within your precompiled header? Currently, I get the following compilation error when following my intuition with this: error C2857: '

Precompiled headers

假装没事ソ 提交于 2019-12-01 16:56:25
What exactly is precompiled headers? when are they used? Precompiled headers are an optimisation used during the compilation process. Basically, if you compile something like stdio.h with the exact same defines and environment, you can safely assume the result will be the same each time. So the compiler remembers the "compiled" version of that header so it doesn't have to do it again. In reality, it tends to be the initial group of headers that makes the difference so, if every one of your source files starts with: #define XYZZY 42 #include <stdio.h> #include <stdlib.h> the first one compiles

Precompiled headers

大城市里の小女人 提交于 2019-12-01 15:39:50
问题 What exactly is precompiled headers? when are they used? 回答1: Precompiled headers are an optimisation used during the compilation process. Basically, if you compile something like stdio.h with the exact same defines and environment, you can safely assume the result will be the same each time. So the compiler remembers the "compiled" version of that header so it doesn't have to do it again. In reality, it tends to be the initial group of headers that makes the difference so, if every one of

PRECOMPILED HEADERS not working in debug build with Qt Creator / qmake / MinGw

。_饼干妹妹 提交于 2019-12-01 07:07:47
In Qt Creator, I have a pro file using PRECOMPILED HEADERS. The build works just perfect when I build in Release mode. But building in Debug mode gives errors, generating object files failing. Example: 17:12:40: Running steps for project Euclide... 17:12:40: Configuration unchanged, skipping qmake step. 17:12:40: Starting: "C:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" C:\Qt\5.2.0\mingw48_32\bin\qmake.exe -spec win32-g++ CONFIG+=debug -o Makefile ..\euclide\Euclide.pro C:/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/UserPrograms/Euclide/build' g

PRECOMPILED HEADERS not working in debug build with Qt Creator / qmake / MinGw

淺唱寂寞╮ 提交于 2019-12-01 04:20:45
问题 In Qt Creator, I have a pro file using PRECOMPILED HEADERS. The build works just perfect when I build in Release mode. But building in Debug mode gives errors, generating object files failing. Example: 17:12:40: Running steps for project Euclide... 17:12:40: Configuration unchanged, skipping qmake step. 17:12:40: Starting: "C:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" C:\Qt\5.2.0\mingw48_32\bin\qmake.exe -spec win32-g++ CONFIG+=debug -o Makefile ..\euclide\Euclide.pro C:/Qt/Tools/mingw48_32

Precompiled headers and compiling universal objects on OSX

青春壹個敷衍的年華 提交于 2019-12-01 03:53:12
We are using precompiled headers with GCC for our project and build them like this: gcc $(CFLAGS) precompiledcommonlib.h Now I'm building the project on OSX 10.6 and trying to use the nifty feature of building for all architectures at the same time like this: gcc $(CFLAGS) -c -arch i386 -arch x86_64 commonlib.c However, it seems this does not work for the precompiled headers: gcc $(CFLAGS) -arch i386 -arch x86_64 precompiledcommonlib.h Undefined symbols for architecture i386: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1

Precompiled headers and compiling universal objects on OSX

本小妞迷上赌 提交于 2019-12-01 00:46:27
问题 We are using precompiled headers with GCC for our project and build them like this: gcc $(CFLAGS) precompiledcommonlib.h Now I'm building the project on OSX 10.6 and trying to use the nifty feature of building for all architectures at the same time like this: gcc $(CFLAGS) -c -arch i386 -arch x86_64 commonlib.c However, it seems this does not work for the precompiled headers: gcc $(CFLAGS) -arch i386 -arch x86_64 precompiledcommonlib.h Undefined symbols for architecture i386: "_main",

Why does stdafx.h work the way it does?

时光怂恿深爱的人放手 提交于 2019-11-30 18:05:25
As usual, when my brain's messing with something I can't figure out myself, I come to you guys for help :) This time I've been wondering why stdafx.h works the way it does? To my understanding it does 2 things: Includes standard headers which we might (?) use and which are rarely changed Work as a compiler-bookmark for when code is no longer precompiled. Now, these 2 things seems like two very different tasks to me, and I wonder why they didn't do two seperate steps to take care of them? To me it seems reasonable to have a #pragma-command do the bookmarking stuff and to optionally have a

Why does stdafx.h work the way it does?

我是研究僧i 提交于 2019-11-30 16:51:34
问题 As usual, when my brain's messing with something I can't figure out myself, I come to you guys for help :) This time I've been wondering why stdafx.h works the way it does? To my understanding it does 2 things: Includes standard headers which we might (?) use and which are rarely changed Work as a compiler-bookmark for when code is no longer precompiled. Now, these 2 things seems like two very different tasks to me, and I wonder why they didn't do two seperate steps to take care of them? To

stdafx.h: When do I need it?

99封情书 提交于 2019-11-30 10:50:01
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 ? If you don't want to use precompiled headers, then there is no point to using a standard include file - this will slow down the build for every file that includes it and cause them to include extra stuff that they do not need. Get rid of it and just include the headers they need. Even without pre-compiled headers stdafx.h could be handy as it groups header