-
Notifications
You must be signed in to change notification settings - Fork 29
Use of Common Headers
LIU Hao edited this page Jul 25, 2023
·
5 revisions
There are three types of common headers:
The forward declarations header
- brings simple standard types, such as
size_t
andint32_t
, by including <stddef.h> and <stdint.h>, respectively. - declares inline functions and macros that are utilized by other headers, such as
max()
. - should be included as the first header by other headers.
- provides forward declarations for everything from the same project.
The general utilities header
- brings complex standard types, such as
std::ostream
, by including <ostream>. - declares functions that are commonly used by all source files.
- shall not be included by other headers from the same project.
- should be included as the last header by other source files.
The pre-compiled header
- includes many potential dependencies, such as <vector> and <algorithm>.
- shall not be included by any headers.
- should be included as the first header by all source files.