4.6.0
Freundlich's C++ toolkit
|
Compiler, OS and warning related macros.
fcppt.config contains macros related to the current implementation. This includes which compiler and operating system is being used. Also, there is a set of headers, called external_begin.hpp
and external_end.hpp
which can be used to ignore warnings in external headers.
In fcppt/config/compiler.hpp
several macros may be defined to identify the current compiler:
Macro | Description |
---|---|
FCPPT_CONFIG_GCC_COMPILER | Defined when the compiler is gcc or clang. clang emulates gcc to a large extent. |
FCPPT_CONFIG_CLANG_COMPILER | Defined when the compiler is clang. |
FCPPT_CONFIG_APPLE_CLANG_COMPILER | Defined when the compiler is the Apple clang compiler (XCode). |
In fcppt/config/platform.hpp
several macros may be defined to identify the operating system:
Macro | Description |
---|---|
FCPPT_CONFIG_WINDOWS_PLATFORM | Defined on Windows (and MinGW). |
FCPPT_CONFIG_UNIX_PLATFORM | Defined on Unix (including Linux). |
FCPPT_CONFIG_POSIX_PLATFORM | Defined on POSIX (including Linux). |
There are many possible warning options for different C++ compilers. To improve quality of code, it is advisable to enable as many of them as possible. The downside is that this will also enable a lot of warnings in files that you include but have no control over. fcppt provides a pair of headers, called fcppt/config/external_begin.hpp
and fcppt/config/external_end.hpp
which can be used to wrap external includes, for example:
To ignore warnings in C headers, fcppt/config/external_begin.h
and fcppt/config/external_end.h
must be used instead.
Sometimes it is necessary to detect if a compiler version is greater or equal to a given version. For example, ignoring certain warning options might only work starting from a specific compiler version:
All the macros evaluate to false when on a different compiler, for example FCPPT_CONFIG_GCC_VERSION_AT_LEAST is always false on clang.
The macros are:
Macro | Header |
---|---|
FCPPT_CONFIG_GCC_VERSION_AT_LEAST | fcppt/config/gcc_version_at_least.hpp |
FCPPT_CONFIG_CLANG_VERSION_AT_LEAST | fcppt/config/clang_version_at_least.hpp |
Macros | |
#define | FCPPT_CONFIG_CLANG_VERSION_AT_LEAST(major, minor) |
Checks if the clang is being used and its version is at least (major, minor) | |
#define | FCPPT_CONFIG_GCC_VERSION_AT_LEAST(major, minor) |
Checks if the gcc is being used and its version is at least (major, minor) | |
#define | FCPPT_CONFIG_MSVC_VERSION_AT_LEAST(version) |
Checks if the msvc is being used and its version is at least version. | |
#define FCPPT_CONFIG_CLANG_VERSION_AT_LEAST | ( | major, | |
minor ) |
Checks if the clang is being used and its version is at least (major, minor)
#define FCPPT_CONFIG_GCC_VERSION_AT_LEAST | ( | major, | |
minor ) |
Checks if the gcc is being used and its version is at least (major, minor)
#define FCPPT_CONFIG_MSVC_VERSION_AT_LEAST | ( | version | ) |
Checks if the msvc is being used and its version is at least version.