Configuring the preprocessor
The preprocessor plays a huge role in the process of building. Maybe this is a little surprising, considering its functionality appears rather straightforward and limited. In the following sections, we'll cover providing paths to included files and using the preprocessor definitions. We'll also explain how we can use CMake to configure included headers.
Providing paths to included files
The most basic feature of the preprocessor is the ability to include .h
and .hpp
header files with the #include
directive which exists in two forms:
- Angle-bracket form:
#include <path-spec>
- Quoted form:
#include "path-spec"
As we know, the preprocessor will replace these directives with the contents of the file specified in path-spec
. Finding these files may be a challenge. Which directories should be searched, and in what order? Unfortunately, the C++ standard doesn't specify that exactly. We have to check the manual for the compiler in use...