1// Copyright 2017 The Abseil Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// -----------------------------------------------------------------------------
16// File: policy_checks.h
17// -----------------------------------------------------------------------------
18//
19// This header enforces a minimum set of policies at build time, such as the
20// supported compiler and library versions. Unsupported configurations are
21// reported with `#error`. This enforcement is best effort, so successfully
22// compiling this header does not guarantee a supported configuration.
23
24// SKIP_ABSL_INLINE_NAMESPACE_CHECK
25
26#ifndef ABSL_BASE_POLICY_CHECKS_H_
27#define ABSL_BASE_POLICY_CHECKS_H_
28
29// Included for the __GLIBC_PREREQ macro used below.
30#include <limits.h>
31
32// Included for the _STLPORT_VERSION macro used below.
33#if defined(__cplusplus)
34#include <cstddef>
35#endif
36
37// -----------------------------------------------------------------------------
38// Operating System Check
39// -----------------------------------------------------------------------------
40
41#if defined(__CYGWIN__)
42#error "Cygwin is not supported."
43#endif
44
45// -----------------------------------------------------------------------------
46// Toolchain Check
47// -----------------------------------------------------------------------------
48
49// We support Visual Studio 2019 (MSVC++ 16.0) and later.
50// This minimum will go up.
51#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
52#error "This package requires Visual Studio 2019 (MSVC++ 16.0) or higher."
53#endif
54
55// We support GCC 7 and later.
56// This minimum will go up.
57#if defined(__GNUC__) && !defined(__clang__)
58#if __GNUC__ < 7
59#error "This package requires GCC 7 or higher."
60#endif
61#endif
62
63// We support Apple Xcode clang 4.2.1 (version 421.11.65) and later.
64// This corresponds to Apple Xcode version 4.5.
65// This minimum will go up.
66#if defined(__apple_build_version__) && __apple_build_version__ < 4211165
67#error "This package requires __apple_build_version__ of 4211165 or higher."
68#endif
69
70// -----------------------------------------------------------------------------
71// C++ Version Check
72// -----------------------------------------------------------------------------
73
74// Enforce C++14 as the minimum.
75#if defined(_MSVC_LANG)
76#if _MSVC_LANG < 201402L
77#error "C++ versions less than C++14 are not supported."
78#endif // _MSVC_LANG < 201402L
79#elif defined(__cplusplus)
80#if __cplusplus < 201402L
81#error "C++ versions less than C++14 are not supported."
82#endif // __cplusplus < 201402L
83#endif
84
85// -----------------------------------------------------------------------------
86// Standard Library Check
87// -----------------------------------------------------------------------------
88
89#if defined(_STLPORT_VERSION)
90#error "STLPort is not supported."
91#endif
92
93// -----------------------------------------------------------------------------
94// `char` Size Check
95// -----------------------------------------------------------------------------
96
97// Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a
98// platform where this is not the case, please provide us with the details about
99// your platform so we can consider relaxing this requirement.
100#if CHAR_BIT != 8
101#error "Abseil assumes CHAR_BIT == 8."
102#endif
103
104// -----------------------------------------------------------------------------
105// `int` Size Check
106// -----------------------------------------------------------------------------
107
108// Abseil currently assumes that an int is 4 bytes. If you would like to use
109// Abseil on a platform where this is not the case, please provide us with the
110// details about your platform so we can consider relaxing this requirement.
111#if INT_MAX < 2147483647
112#error "Abseil assumes that int is at least 4 bytes. "
113#endif
114
115#endif // ABSL_BASE_POLICY_CHECKS_H_
116