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#ifndef ABSL_BASE_POLICY_CHECKS_H_
25#define ABSL_BASE_POLICY_CHECKS_H_
26
27// Included for the __GLIBC_PREREQ macro used below.
28#include <limits.h>
29
30// Included for the _STLPORT_VERSION macro used below.
31#if defined(__cplusplus)
32#include <cstddef>
33#endif
34
35// -----------------------------------------------------------------------------
36// Operating System Check
37// -----------------------------------------------------------------------------
38
39#if defined(__CYGWIN__)
40#error "Cygwin is not supported."
41#endif
42
43// -----------------------------------------------------------------------------
44// Toolchain Check
45// -----------------------------------------------------------------------------
46
47// We support Visual Studio 2019 (MSVC++ 16.0) and later.
48// This minimum will go up.
49#if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
50#error "This package requires Visual Studio 2019 (MSVC++ 16.0) or higher."
51#endif
52
53// We support GCC 7 and later.
54// This minimum will go up.
55#if defined(__GNUC__) && !defined(__clang__)
56#if __GNUC__ < 7
57#error "This package requires GCC 7 or higher."
58#endif
59#endif
60
61// We support Apple Xcode clang 4.2.1 (version 421.11.65) and later.
62// This corresponds to Apple Xcode version 4.5.
63// This minimum will go up.
64#if defined(__apple_build_version__) && __apple_build_version__ < 4211165
65#error "This package requires __apple_build_version__ of 4211165 or higher."
66#endif
67
68// -----------------------------------------------------------------------------
69// C++ Version Check
70// -----------------------------------------------------------------------------
71
72// Enforce C++14 as the minimum.
73#if defined(_MSVC_LANG)
74#if _MSVC_LANG < 201402L
75#error "C++ versions less than C++14 are not supported."
76#endif // _MSVC_LANG < 201402L
77#elif defined(__cplusplus)
78#if __cplusplus < 201402L
79#error "C++ versions less than C++14 are not supported."
80#endif // __cplusplus < 201402L
81#endif
82
83// -----------------------------------------------------------------------------
84// Standard Library Check
85// -----------------------------------------------------------------------------
86
87#if defined(_STLPORT_VERSION)
88#error "STLPort is not supported."
89#endif
90
91// -----------------------------------------------------------------------------
92// `char` Size Check
93// -----------------------------------------------------------------------------
94
95// Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a
96// platform where this is not the case, please provide us with the details about
97// your platform so we can consider relaxing this requirement.
98#if CHAR_BIT != 8
99#error "Abseil assumes CHAR_BIT == 8."
100#endif
101
102// -----------------------------------------------------------------------------
103// `int` Size Check
104// -----------------------------------------------------------------------------
105
106// Abseil currently assumes that an int is 4 bytes. If you would like to use
107// Abseil on a platform where this is not the case, please provide us with the
108// details about your platform so we can consider relaxing this requirement.
109#if INT_MAX < 2147483647
110#error "Abseil assumes that int is at least 4 bytes. "
111#endif
112
113#endif // ABSL_BASE_POLICY_CHECKS_H_
114