Overview
Okay, so if you're programming in C++, and you don't know what Precompiled Headers are, chances are that compiling a project takes you something like 4 seconds, and on bigger projects it can even take 20 seconds, and much more just for a simple build.

Obviously, this gets very frustrating.
So if this is the case, this tutorial is a gold-mine for you. this knowledge was for me when I learned it.

Precompiled Headers have literal meaning.
They are headers, that the compiler compiles, then saving them in a file (which I'll describe soon), and uses that file when compiling (which leads to saving you a lot of time).

How?
Instead of building the header files over and over again, at each build, we just hold that information inside a file.
Usualy it ends with the extension .pch and .gch.

So how can we do it?
We create a header file. usually called stdafx.h. it will hold the header files we want to precompile.
Those header files would usually be specific headers that we use frequently in the project.
We'll then create a cpp file that will #include the stdafx.h file we created.
We'll let the compiler know we want to use precompiled headers.
And finally, we'll use them, simply by including stdafx.h.

So let's begin:

Creating stdafx.h
Create a header file, name it stdafx.h for learning purposes. you can actually name it however you want but it's usually named like so.
In the file use the directive #pragma once, and then you can begin inserting the header files you're using. for this instance I'll use Windows.h

stdafx.h

#pragma once
#include <Windows.h>
// You can #include much more header here of course. this is the place!

Creating stdafx.cpp

Now you'll need to create another file, that will just include the header file we just created.
Name it stdafx.cpp for now (once again, you can name it however you want).
You just include stdafx.h here! YOU DO NOT INCLUDE ANY MORE HEADER FILES HERE!

stdafx.cpp

#include "stdafx.h"

That's it.. that's the whole file.

Setting the compiler* I'm using Visual Studio. if you use a different compiler, find out how it is done by yours.

Now, we got our files but they're no different from any other files in our project (and in their essence - they are).
So we need to let the compiler know they are actually precompiled headers, and not just source code.