policy_checks.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #ifndef ABSL_BASE_POLICY_CHECKS_H_
  24. #define ABSL_BASE_POLICY_CHECKS_H_
  25. // Included for the __GLIBC_PREREQ macro used below.
  26. #include <limits.h>
  27. // Included for the _STLPORT_VERSION macro used below.
  28. #if defined(__cplusplus)
  29. #include <cstddef>
  30. #endif
  31. // -----------------------------------------------------------------------------
  32. // Operating System Check
  33. // -----------------------------------------------------------------------------
  34. #if defined(__CYGWIN__)
  35. #error "Cygwin is not supported."
  36. #endif
  37. // -----------------------------------------------------------------------------
  38. // Toolchain Check
  39. // -----------------------------------------------------------------------------
  40. // We support MSVC++ 14.0 update 2 and later.
  41. // This minimum will go up.
  42. #if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918 && !defined(__clang__)
  43. #error "This package requires Visual Studio 2015 Update 2 or higher."
  44. #endif
  45. // We support gcc 4.7 and later.
  46. // This minimum will go up.
  47. #if defined(__GNUC__) && !defined(__clang__)
  48. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
  49. #error "This package requires gcc 4.7 or higher."
  50. #endif
  51. #endif
  52. // We support Apple Xcode clang 4.2.1 (version 421.11.65) and later.
  53. // This corresponds to Apple Xcode version 4.5.
  54. // This minimum will go up.
  55. #if defined(__apple_build_version__) && __apple_build_version__ < 4211165
  56. #error "This package requires __apple_build_version__ of 4211165 or higher."
  57. #endif
  58. // -----------------------------------------------------------------------------
  59. // C++ Version Check
  60. // -----------------------------------------------------------------------------
  61. // Enforce C++11 as the minimum. Note that Visual Studio has not
  62. // advanced __cplusplus despite being good enough for our purposes, so
  63. // so we exempt it from the check.
  64. #if defined(__cplusplus) && !defined(_MSC_VER)
  65. #if __cplusplus < 201103L
  66. #error "C++ versions less than C++11 are not supported."
  67. #endif
  68. #endif
  69. // -----------------------------------------------------------------------------
  70. // Standard Library Check
  71. // -----------------------------------------------------------------------------
  72. #if defined(_STLPORT_VERSION)
  73. #error "STLPort is not supported."
  74. #endif
  75. // -----------------------------------------------------------------------------
  76. // `char` Size Check
  77. // -----------------------------------------------------------------------------
  78. // Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a
  79. // platform where this is not the case, please provide us with the details about
  80. // your platform so we can consider relaxing this requirement.
  81. #if CHAR_BIT != 8
  82. #error "Abseil assumes CHAR_BIT == 8."
  83. #endif
  84. // -----------------------------------------------------------------------------
  85. // `int` Size Check
  86. // -----------------------------------------------------------------------------
  87. // Abseil currently assumes that an int is 4 bytes. If you would like to use
  88. // Abseil on a platform where this is not the case, please provide us with the
  89. // details about your platform so we can consider relaxing this requirement.
  90. #if INT_MAX < 2147483647
  91. #error "Abseil assumes that int is at least 4 bytes. "
  92. #endif
  93. #endif // ABSL_BASE_POLICY_CHECKS_H_