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 | // Compiler Check |
45 | // ----------------------------------------------------------------------------- |
46 | |
47 | // We support MSVC++ 14.0 update 2 and later. |
48 | // This minimum will go up. |
49 | #if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918 && !defined(__clang__) |
50 | #error "This package requires Visual Studio 2015 Update 2 or higher." |
51 | #endif |
52 | |
53 | // We support gcc 4.7 and later. |
54 | // This minimum will go up. |
55 | #if defined(__GNUC__) && !defined(__clang__) |
56 | #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) |
57 | #error "This package requires gcc 4.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++11 as the minimum. Note that Visual Studio has not |
73 | // advanced __cplusplus despite being good enough for our purposes, so |
74 | // so we exempt it from the check. |
75 | #if defined(__cplusplus) && !defined(_MSC_VER) |
76 | #if __cplusplus < 201103L |
77 | #error "C++ versions less than C++11 are not supported." |
78 | #endif |
79 | #endif |
80 | |
81 | // ----------------------------------------------------------------------------- |
82 | // Standard Library Check |
83 | // ----------------------------------------------------------------------------- |
84 | |
85 | // We have chosen glibc 2.12 as the minimum as it was tagged for release |
86 | // in May, 2010 and includes some functionality used in Google software |
87 | // (for instance pthread_setname_np): |
88 | // https://sourceware.org/ml/libc-alpha/2010-05/msg00000.html |
89 | #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) |
90 | #if !__GLIBC_PREREQ(2, 12) |
91 | #error "Minimum required version of glibc is 2.12." |
92 | #endif |
93 | #endif |
94 | |
95 | #if defined(_STLPORT_VERSION) |
96 | #error "STLPort is not supported." |
97 | #endif |
98 | |
99 | // ----------------------------------------------------------------------------- |
100 | // `char` Size Check |
101 | // ----------------------------------------------------------------------------- |
102 | |
103 | // Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a |
104 | // platform where this is not the case, please provide us with the details about |
105 | // your platform so we can consider relaxing this requirement. |
106 | #if CHAR_BIT != 8 |
107 | #error "Abseil assumes CHAR_BIT == 8." |
108 | #endif |
109 | |
110 | // ----------------------------------------------------------------------------- |
111 | // `int` Size Check |
112 | // ----------------------------------------------------------------------------- |
113 | |
114 | // Abseil currently assumes that an int is 4 bytes. If you would like to use |
115 | // Abseil on a platform where this is not the case, please provide us with the |
116 | // details about your platform so we can consider relaxing this requirement. |
117 | #if INT_MAX < 2147483647 |
118 | #error "Abseil assumes that int is at least 4 bytes. " |
119 | #endif |
120 | |
121 | #endif // ABSL_BASE_POLICY_CHECKS_H_ |
122 | |