Inclusion Guards

Just to clear up what we’re talking about, an inclusion guard looks like this:

#ifndef HEADER_FILE_H
#define HEADER_FILE_H

...//your header

#endif //HEADER_FILE_H

It consists of three preprocessor directives around the code of your header file.

Most IDEs add these for you automatically when you create a header, but it’s well worth having an appreciation of why they are there.

Read moreInclusion Guards

What Does The Preprocessor Do?

What a jolly good question.

The preprocessor takes a look at your source code just before it goes off to the compiler, does a little formatting, and carries out any instructions you have given it.

Like what?

Well, preprocessor instructions are called preprocessor directives, and they all start with a #.

Like #include?

Exactly.

Each # command that the preprocessor encounters results in a modification to the source code in some way. Let’s take a look at them briefly in turn, and then we’ll see what goes on behind the scenes.

Read moreWhat Does The Preprocessor Do?