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