00001 // Copyright 2017 The Abseil Authors. 00002 // 00003 // Licensed under the Apache License, Version 2.0 (the "License"); 00004 // you may not use this file except in compliance with the License. 00005 // You may obtain a copy of the License at 00006 // 00007 // https://www.apache.org/licenses/LICENSE-2.0 00008 // 00009 // Unless required by applicable law or agreed to in writing, software 00010 // distributed under the License is distributed on an "AS IS" BASIS, 00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 // See the License for the specific language governing permissions and 00013 // limitations under the License. 00014 // 00015 // ----------------------------------------------------------------------------- 00016 // File: policy_checks.h 00017 // ----------------------------------------------------------------------------- 00018 // 00019 // This header enforces a minimum set of policies at build time, such as the 00020 // supported compiler and library versions. Unsupported configurations are 00021 // reported with `#error`. This enforcement is best effort, so successfully 00022 // compiling this header does not guarantee a supported configuration. 00023 00024 #ifndef ABSL_BASE_POLICY_CHECKS_H_ 00025 #define ABSL_BASE_POLICY_CHECKS_H_ 00026 00027 // Included for the __GLIBC_PREREQ macro used below. 00028 #include <limits.h> 00029 00030 // Included for the _STLPORT_VERSION macro used below. 00031 #if defined(__cplusplus) 00032 #include <cstddef> 00033 #endif 00034 00035 // ----------------------------------------------------------------------------- 00036 // Operating System Check 00037 // ----------------------------------------------------------------------------- 00038 00039 #if defined(__CYGWIN__) 00040 #error "Cygwin is not supported." 00041 #endif 00042 00043 // ----------------------------------------------------------------------------- 00044 // Compiler Check 00045 // ----------------------------------------------------------------------------- 00046 00047 // We support MSVC++ 14.0 update 2 and later. 00048 // This minimum will go up. 00049 #if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918 && !defined(__clang__) 00050 #error "This package requires Visual Studio 2015 Update 2 or higher." 00051 #endif 00052 00053 // We support gcc 4.7 and later. 00054 // This minimum will go up. 00055 #if defined(__GNUC__) && !defined(__clang__) 00056 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) 00057 #error "This package requires gcc 4.7 or higher." 00058 #endif 00059 #endif 00060 00061 // We support Apple Xcode clang 4.2.1 (version 421.11.65) and later. 00062 // This corresponds to Apple Xcode version 4.5. 00063 // This minimum will go up. 00064 #if defined(__apple_build_version__) && __apple_build_version__ < 4211165 00065 #error "This package requires __apple_build_version__ of 4211165 or higher." 00066 #endif 00067 00068 // ----------------------------------------------------------------------------- 00069 // C++ Version Check 00070 // ----------------------------------------------------------------------------- 00071 00072 // Enforce C++11 as the minimum. Note that Visual Studio has not 00073 // advanced __cplusplus despite being good enough for our purposes, so 00074 // so we exempt it from the check. 00075 #if defined(__cplusplus) && !defined(_MSC_VER) 00076 #if __cplusplus < 201103L 00077 #error "C++ versions less than C++11 are not supported." 00078 #endif 00079 #endif 00080 00081 // ----------------------------------------------------------------------------- 00082 // Standard Library Check 00083 // ----------------------------------------------------------------------------- 00084 00085 // We have chosen glibc 2.12 as the minimum as it was tagged for release 00086 // in May, 2010 and includes some functionality used in Google software 00087 // (for instance pthread_setname_np): 00088 // https://sourceware.org/ml/libc-alpha/2010-05/msg00000.html 00089 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) 00090 #if !__GLIBC_PREREQ(2, 12) 00091 #error "Minimum required version of glibc is 2.12." 00092 #endif 00093 #endif 00094 00095 #if defined(_STLPORT_VERSION) 00096 #error "STLPort is not supported." 00097 #endif 00098 00099 // ----------------------------------------------------------------------------- 00100 // `char` Size Check 00101 // ----------------------------------------------------------------------------- 00102 00103 // Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a 00104 // platform where this is not the case, please provide us with the details about 00105 // your platform so we can consider relaxing this requirement. 00106 #if CHAR_BIT != 8 00107 #error "Abseil assumes CHAR_BIT == 8." 00108 #endif 00109 00110 // ----------------------------------------------------------------------------- 00111 // `int` Size Check 00112 // ----------------------------------------------------------------------------- 00113 00114 // Abseil currently assumes that an int is 4 bytes. If you would like to use 00115 // Abseil on a platform where this is not the case, please provide us with the 00116 // details about your platform so we can consider relaxing this requirement. 00117 #if INT_MAX < 2147483647 00118 #error "Abseil assumes that int is at least 4 bytes. " 00119 #endif 00120 00121 #endif // ABSL_BASE_POLICY_CHECKS_H_