policy_checks.h 4.2 KB

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