options.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #ifndef OTABSL_BASE_OPTIONS_H_
  2. #define OTABSL_BASE_OPTIONS_H_
  3. // Copyright 2019 The Abseil Authors.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // https://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. // -----------------------------------------------------------------------------
  18. // File: options.h
  19. // -----------------------------------------------------------------------------
  20. //
  21. // This file contains Abseil configuration options for setting specific
  22. // implementations instead of letting Abseil determine which implementation to
  23. // use at compile-time. Setting these options may be useful for package or build
  24. // managers who wish to guarantee ABI stability within binary builds (which are
  25. // otherwise difficult to enforce).
  26. //
  27. // *** IMPORTANT NOTICE FOR PACKAGE MANAGERS: It is important that
  28. // maintainers of package managers who wish to package Abseil read and
  29. // understand this file! ***
  30. //
  31. // Abseil contains a number of possible configuration endpoints, based on
  32. // parameters such as the detected platform, language version, or command-line
  33. // flags used to invoke the underlying binary. As is the case with all
  34. // libraries, binaries which contain Abseil code must ensure that separate
  35. // packages use the same compiled copy of Abseil to avoid a diamond dependency
  36. // problem, which can occur if two packages built with different Abseil
  37. // configuration settings are linked together. Diamond dependency problems in
  38. // C++ may manifest as violations to the One Definition Rule (ODR) (resulting in
  39. // linker errors), or undefined behavior (resulting in crashes).
  40. //
  41. // Diamond dependency problems can be avoided if all packages utilize the same
  42. // exact version of Abseil. Building from source code with the same compilation
  43. // parameters is the easiest way to avoid such dependency problems. However, for
  44. // package managers who cannot control such compilation parameters, we are
  45. // providing the file to allow you to inject ABI (Application Binary Interface)
  46. // stability across builds. Settings options in this file will neither change
  47. // API nor ABI, providing a stable copy of Abseil between packages.
  48. //
  49. // Care must be taken to keep options within these configurations isolated
  50. // from any other dynamic settings, such as command-line flags which could alter
  51. // these options. This file is provided specifically to help build and package
  52. // managers provide a stable copy of Abseil within their libraries and binaries;
  53. // other developers should not have need to alter the contents of this file.
  54. //
  55. // -----------------------------------------------------------------------------
  56. // Usage
  57. // -----------------------------------------------------------------------------
  58. //
  59. // For any particular package release, set the appropriate definitions within
  60. // this file to whatever value makes the most sense for your package(s). Note
  61. // that, by default, most of these options, at the moment, affect the
  62. // implementation of types; future options may affect other implementation
  63. // details.
  64. //
  65. // NOTE: the defaults within this file all assume that Abseil can select the
  66. // proper Abseil implementation at compile-time, which will not be sufficient
  67. // to guarantee ABI stability to package managers.
  68. // Include a standard library header to allow configuration based on the
  69. // standard library in use.
  70. // Using C++20 feature-test macros when possible, otherwise fall back to
  71. // ciso646/iso646.h.There are warnings when including ciso646 in C++17 mode
  72. #ifdef __has_include
  73. # if __has_include(<version>)
  74. # include <version>
  75. # endif
  76. #elif defined(_MSC_VER) && \
  77. ((defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L))
  78. # if _MSC_VER >= 1922
  79. # include <version>
  80. # endif
  81. #else
  82. # if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
  83. # pragma GCC diagnostic push
  84. # pragma GCC diagnostic ignored "-Wcpp"
  85. # elif defined(__clang__) || defined(__apple_build_version__)
  86. # pragma clang diagnostic push
  87. # pragma clang diagnostic ignored "-Wcpp"
  88. # endif
  89. # include <ciso646>
  90. # if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__)
  91. # pragma GCC diagnostic pop
  92. # elif defined(__clang__) || defined(__apple_build_version__)
  93. # pragma clang diagnostic pop
  94. # endif
  95. #endif
  96. // -----------------------------------------------------------------------------
  97. // Type Compatibility Options
  98. // -----------------------------------------------------------------------------
  99. //
  100. // OTABSL_OPTION_USE_STD_ANY
  101. //
  102. // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is implemented as an alias to
  103. // std::any, or as an independent implementation.
  104. //
  105. // A value of 0 means to use Abseil's implementation. This requires only C++11
  106. // support, and is expected to work on every toolchain we support.
  107. //
  108. // A value of 1 means to use an alias to std::any. This requires that all code
  109. // using Abseil is built in C++17 mode or later.
  110. //
  111. // A value of 2 means to detect the C++ version being used to compile Abseil,
  112. // and use an alias only if a working std::any is available. This option is
  113. // useful when you are building your entire program, including all of its
  114. // dependencies, from source. It should not be used otherwise -- for example,
  115. // if you are distributing Abseil in a binary package manager -- since in
  116. // mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::any will name a different type, with a different mangled name
  117. // and binary layout, depending on the compiler flags passed by the end user.
  118. // For more info, see https://abseil.io/about/design/dropin-types.
  119. //
  120. // User code should not inspect this macro. To check in the preprocessor if
  121. // absl::OTABSL_OPTION_NAMESPACE_NAME::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY.
  122. #define OTABSL_OPTION_USE_STD_ANY 0
  123. // OTABSL_OPTION_USE_STD_OPTIONAL
  124. //
  125. // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is implemented as an alias to
  126. // std::optional, or as an independent implementation.
  127. //
  128. // A value of 0 means to use Abseil's implementation. This requires only C++11
  129. // support, and is expected to work on every toolchain we support.
  130. //
  131. // A value of 1 means to use an alias to std::optional. This requires that all
  132. // code using Abseil is built in C++17 mode or later.
  133. //
  134. // A value of 2 means to detect the C++ version being used to compile Abseil,
  135. // and use an alias only if a working std::optional is available. This option
  136. // is useful when you are building your program from source. It should not be
  137. // used otherwise -- for example, if you are distributing Abseil in a binary
  138. // package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::optional will name a different
  139. // type, with a different mangled name and binary layout, depending on the
  140. // compiler flags passed by the end user. For more info, see
  141. // https://abseil.io/about/design/dropin-types.
  142. // User code should not inspect this macro. To check in the preprocessor if
  143. // absl::OTABSL_OPTION_NAMESPACE_NAME::optional is a typedef of std::optional, use the feature macro
  144. // OTABSL_USES_STD_OPTIONAL.
  145. #define OTABSL_OPTION_USE_STD_OPTIONAL 0
  146. // OTABSL_OPTION_USE_STD_STRING_VIEW
  147. //
  148. // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is implemented as an alias to
  149. // std::string_view, or as an independent implementation.
  150. //
  151. // A value of 0 means to use Abseil's implementation. This requires only C++11
  152. // support, and is expected to work on every toolchain we support.
  153. //
  154. // A value of 1 means to use an alias to std::string_view. This requires that
  155. // all code using Abseil is built in C++17 mode or later.
  156. //
  157. // A value of 2 means to detect the C++ version being used to compile Abseil,
  158. // and use an alias only if a working std::string_view is available. This
  159. // option is useful when you are building your program from source. It should
  160. // not be used otherwise -- for example, if you are distributing Abseil in a
  161. // binary package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::string_view will name a
  162. // different type, with a different mangled name and binary layout, depending on
  163. // the compiler flags passed by the end user. For more info, see
  164. // https://abseil.io/about/design/dropin-types.
  165. //
  166. // User code should not inspect this macro. To check in the preprocessor if
  167. // absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is a typedef of std::string_view, use the feature macro
  168. // OTABSL_USES_STD_STRING_VIEW.
  169. #define OTABSL_OPTION_USE_STD_STRING_VIEW 0
  170. // OTABSL_OPTION_USE_STD_VARIANT
  171. //
  172. // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is implemented as an alias to
  173. // std::variant, or as an independent implementation.
  174. //
  175. // A value of 0 means to use Abseil's implementation. This requires only C++11
  176. // support, and is expected to work on every toolchain we support.
  177. //
  178. // A value of 1 means to use an alias to std::variant. This requires that all
  179. // code using Abseil is built in C++17 mode or later.
  180. //
  181. // A value of 2 means to detect the C++ version being used to compile Abseil,
  182. // and use an alias only if a working std::variant is available. This option
  183. // is useful when you are building your program from source. It should not be
  184. // used otherwise -- for example, if you are distributing Abseil in a binary
  185. // package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::variant will name a different
  186. // type, with a different mangled name and binary layout, depending on the
  187. // compiler flags passed by the end user. For more info, see
  188. // https://abseil.io/about/design/dropin-types.
  189. //
  190. // User code should not inspect this macro. To check in the preprocessor if
  191. // absl::OTABSL_OPTION_NAMESPACE_NAME::variant is a typedef of std::variant, use the feature macro
  192. // OTABSL_USES_STD_VARIANT.
  193. #define OTABSL_OPTION_USE_STD_VARIANT 0
  194. // OTABSL_OPTION_NAMESPACE_NAME
  195. //
  196. // All codes in otabsl are under OTABSL_OPTION_NAMESPACE_NAME, we do not use inline namespace to avoid
  197. // conlict with external Abseil.
  198. #define OTABSL_OPTION_NAMESPACE_NAME otel_v1
  199. #endif // OTABSL_BASE_OPTIONS_H_