2.10.0
Freundlich's C++ toolkit
Macros
fcppt.config

Description

Compiler, OS and warning related macros.

Introduction

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.

Compiler and OS detection

Compiler Detection

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).

OS Detection

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).

Ignoring warnings in external headers

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:

#include <fcppt/config/external_begin.hpp>
#include <type_traits>
#include <fcppt/config/external_end.hpp>

To ignore warnings in C headers, fcppt/config/external_begin.h and fcppt/config/external_end.h must be used instead.

Compiler versions

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:

#include <fcppt/config/gcc_version_at_least.hpp>
#if FCPPT_CONFIG_GCC_VERSION_AT_LEAST(4, 9) && !FCPPT_CONFIG_GCC_VERSION_AT_LEAST(6, 0)
#include <fcppt/preprocessor/disable_gcc_warning.hpp>
FCPPT_PP_DISABLE_GCC_WARNING(-Wfloat-conversion)
#endif

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) More...
 
#define FCPPT_CONFIG_GCC_VERSION_AT_LEAST(major, minor)
 Checks if the gcc is being used and its version is at least (major, minor) More...
 
#define FCPPT_CONFIG_MSVC_VERSION_AT_LEAST(version)
 Checks if the msvc is being used and its version is at least version. More...
 

Macro Definition Documentation

◆ FCPPT_CONFIG_CLANG_VERSION_AT_LEAST

#define FCPPT_CONFIG_CLANG_VERSION_AT_LEAST (   major,
  minor 
)
Value:
FCPPT_CONFIG_DETAIL_CLANG_VERSION_AT_LEAST(\
major,\
minor\
)

Checks if the clang is being used and its version is at least (major, minor)

◆ FCPPT_CONFIG_GCC_VERSION_AT_LEAST

#define FCPPT_CONFIG_GCC_VERSION_AT_LEAST (   major,
  minor 
)
Value:
FCPPT_CONFIG_DETAIL_GCC_VERSION_AT_LEAST(\
major,\
minor \
)

Checks if the gcc is being used and its version is at least (major, minor)

◆ FCPPT_CONFIG_MSVC_VERSION_AT_LEAST

#define FCPPT_CONFIG_MSVC_VERSION_AT_LEAST (   version)
Value:
FCPPT_CONFIG_DETAIL_MSVC_VERSION_AT_LEAST(\
version\
)

Checks if the msvc is being used and its version is at least version.