policy_checks.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 Visual Studio 2019 (MSVC++ 16.0) and later.
  41. // This minimum will go up.
  42. #if defined(_MSC_VER) && _MSC_VER < 1920 && !defined(__clang__)
  43. #error "This package requires Visual Studio 2019 (MSVC++ 16.0) or higher."
  44. #endif
  45. // We support GCC 7 and later.
  46. // This minimum will go up.
  47. #if defined(__GNUC__) && !defined(__clang__)
  48. #if __GNUC__ < 7
  49. #error "This package requires GCC 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++14 as the minimum.
  62. #if defined(_MSVC_LANG)
  63. #if _MSVC_LANG < 201402L
  64. #error "C++ versions less than C++14 are not supported."
  65. #endif // _MSVC_LANG < 201402L
  66. #elif defined(__cplusplus)
  67. #if __cplusplus < 201402L
  68. #error "C++ versions less than C++14 are not supported."
  69. #endif // __cplusplus < 201402L
  70. #endif
  71. // -----------------------------------------------------------------------------
  72. // Standard Library Check
  73. // -----------------------------------------------------------------------------
  74. #if defined(_STLPORT_VERSION)
  75. #error "STLPort is not supported."
  76. #endif
  77. // -----------------------------------------------------------------------------
  78. // `char` Size Check
  79. // -----------------------------------------------------------------------------
  80. // Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a
  81. // platform where this is not the case, please provide us with the details about
  82. // your platform so we can consider relaxing this requirement.
  83. #if CHAR_BIT != 8
  84. #error "Abseil assumes CHAR_BIT == 8."
  85. #endif
  86. // -----------------------------------------------------------------------------
  87. // `int` Size Check
  88. // -----------------------------------------------------------------------------
  89. // Abseil currently assumes that an int is 4 bytes. If you would like to use
  90. // Abseil on a platform where this is not the case, please provide us with the
  91. // details about your platform so we can consider relaxing this requirement.
  92. #if INT_MAX < 2147483647
  93. #error "Abseil assumes that int is at least 4 bytes. "
  94. #endif
  95. #endif // ABSL_BASE_POLICY_CHECKS_H_