From 68589f5c3ae50b8972051727919cd85c84f7c703 Mon Sep 17 00:00:00 2001 From: rob100 Date: Thu, 6 Aug 2015 11:18:43 +0200 Subject: [PATCH 1/3] Precompiled Header Filled the section about precompiled headers with some general information and some links to a manual for the common compiler --- 08-Considering_Performance.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/08-Considering_Performance.md b/08-Considering_Performance.md index 992b247..f4968d9 100644 --- a/08-Considering_Performance.md +++ b/08-Considering_Performance.md @@ -62,6 +62,9 @@ This is a general form of "Firewall Frequently Changing Header Files" and "Don't ### Consider using precompiled headers +The usage of precompiled headers can considerably reduce the compile time in large projects. Selected headers are compiled to an intermediate form that can be faster processed by the compiler. It is recommended to define only frequently used header that changes rarely as precompiled header (e.g. system and library headers) to achieve the compile time reduction. +But there is no standard way to use them, every compiler has their own way. Precompiled headers is supported by the most common compiler, like [GCC](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html), [Clang](http://clang.llvm.org/docs/PCHInternals.html) and [Visual Studio](https://msdn.microsoft.com/en-us/library/szfdksca.aspx). + ### Consider Using Tools These are not meant to supersede good design From 0a9dfb1ce2c816e41c0ee85b90e12dcf8e691122 Mon Sep 17 00:00:00 2001 From: rob100 Date: Mon, 24 Aug 2015 13:38:33 +0200 Subject: [PATCH 2/3] Added more disadvantages for precompiled headers --- 08-Considering_Performance.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/08-Considering_Performance.md b/08-Considering_Performance.md index f4968d9..596ba80 100644 --- a/08-Considering_Performance.md +++ b/08-Considering_Performance.md @@ -62,8 +62,14 @@ This is a general form of "Firewall Frequently Changing Header Files" and "Don't ### Consider using precompiled headers -The usage of precompiled headers can considerably reduce the compile time in large projects. Selected headers are compiled to an intermediate form that can be faster processed by the compiler. It is recommended to define only frequently used header that changes rarely as precompiled header (e.g. system and library headers) to achieve the compile time reduction. -But there is no standard way to use them, every compiler has their own way. Precompiled headers is supported by the most common compiler, like [GCC](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html), [Clang](http://clang.llvm.org/docs/PCHInternals.html) and [Visual Studio](https://msdn.microsoft.com/en-us/library/szfdksca.aspx). +The usage of precompiled headers can considerably reduce the compile time in large projects. Selected headers are compiled to an intermediate form (PCH files) that can be faster processed by the compiler. It is recommended to define only frequently used header that changes rarely as precompiled header (e.g. system and library headers) to achieve the compile time reduction. +But you have to keep in mind, that using precompiled headers has several disadvantages: +* The usage of precompiled header is not portable. +* The generated PCH files are machine dependent. +* The generated PCH files can be quite large. +* It can break your header dependencies. Because of the precompiled headers, every file has the possibility to include every header that is marked as a precompiled header. In result it can happen, that the build fails if you disable the precompiled headers. This can be an issue if you ship something like a library. Because of this it is highly recommend to build once with precompiled header enabled and a second time without them. + +Precompiled headers is supported by the most common compiler, like [GCC](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html), [Clang](http://clang.llvm.org/docs/PCHInternals.html) and [Visual Studio](https://msdn.microsoft.com/en-us/library/szfdksca.aspx). ### Consider Using Tools From 1620934aa5c9d4fee5a819700401aa3ac3e6bbd4 Mon Sep 17 00:00:00 2001 From: rob100 Date: Mon, 24 Aug 2015 13:49:43 +0200 Subject: [PATCH 3/3] Added information about cotire --- 08-Considering_Performance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/08-Considering_Performance.md b/08-Considering_Performance.md index 596ba80..cfa2821 100644 --- a/08-Considering_Performance.md +++ b/08-Considering_Performance.md @@ -70,6 +70,7 @@ But you have to keep in mind, that using precompiled headers has several disadva * It can break your header dependencies. Because of the precompiled headers, every file has the possibility to include every header that is marked as a precompiled header. In result it can happen, that the build fails if you disable the precompiled headers. This can be an issue if you ship something like a library. Because of this it is highly recommend to build once with precompiled header enabled and a second time without them. Precompiled headers is supported by the most common compiler, like [GCC](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html), [Clang](http://clang.llvm.org/docs/PCHInternals.html) and [Visual Studio](https://msdn.microsoft.com/en-us/library/szfdksca.aspx). +Tools like [cotire](https://github.com/sakra/cotire/) (a plugin for cmake) can help you to add precompiled headers to your build system. ### Consider Using Tools