NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/nostd/internal/absl/base/config.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
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  * http://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 #ifndef OTABSL_BASE_CONFIG_H_
19 #define OTABSL_BASE_CONFIG_H_
20 
21 // Included for the __GLIBC__ macro (or similar macros on other systems).
22 #include <limits.h>
23 
24 #ifdef __cplusplus
25 // Included for __GLIBCXX__, _LIBCPP_VERSION
26 #include <cstddef>
27 #endif // __cplusplus
28 
29 #if defined(__APPLE__)
30 // Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED,
31 // __IPHONE_8_0.
32 #include <Availability.h>
33 #include <TargetConditionals.h>
34 #endif
35 
36 #include "options.h"
37 #include "policy_checks.h"
38 
39 // Helper macro to convert a CPP variable to a string literal.
40 #define OTABSL_INTERNAL_DO_TOKEN_STR(x) #x
41 #define OTABSL_INTERNAL_TOKEN_STR(x) OTABSL_INTERNAL_DO_TOKEN_STR(x)
42 
43 // -----------------------------------------------------------------------------
44 // Abseil namespace annotations
45 // -----------------------------------------------------------------------------
46 
47 // OTABSL_NAMESPACE_BEGIN/OTABSL_NAMESPACE_END
48 //
49 // An annotation placed at the beginning/end of each `namespace absl` scope.
50 // This is used to inject an inline namespace.
51 //
52 // The proper way to write Abseil code in the `absl` namespace is:
53 //
54 // namespace absl {
55 // OTABSL_NAMESPACE_BEGIN
56 //
57 // void Foo(); // absl::OTABSL_OPTION_NAMESPACE_NAME::Foo().
58 //
59 // OTABSL_NAMESPACE_END
60 // } // namespace absl
61 //
62 // Users of Abseil should not use these macros, because users of Abseil should
63 // not write `namespace absl {` in their own code for any reason. (Abseil does
64 // not support forward declarations of its own types, nor does it support
65 // user-provided specialization of Abseil templates. Code that violates these
66 // rules may be broken without warning.)
67 #if !defined(OTABSL_OPTION_NAMESPACE_NAME)
68 #error options.h is misconfigured.
69 #endif
70 
71 // Check that OTABSL_OPTION_NAMESPACE_NAME is neither "head" nor ""
72 #if defined(__cplusplus)
73 
74 #define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \
75  OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME)
76 
77 static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0',
78  "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must "
79  "not be empty.");
80 static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
81  OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' ||
82  OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' ||
83  OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' ||
84  OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0',
85  "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must "
86  "be changed to a new, unique identifier name.");
87 
88 #endif
89 
90 
91 #define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME {
92 #define OTABSL_NAMESPACE_END }
93 
94 // -----------------------------------------------------------------------------
95 // Compiler Feature Checks
96 // -----------------------------------------------------------------------------
97 
98 // OTABSL_HAVE_BUILTIN()
99 //
100 // Checks whether the compiler supports a Clang Feature Checking Macro, and if
101 // so, checks whether it supports the provided builtin function "x" where x
102 // is one of the functions noted in
103 // https://clang.llvm.org/docs/LanguageExtensions.html
104 //
105 // Note: Use this macro to avoid an extra level of #ifdef __has_builtin check.
106 // http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html
107 #ifdef __has_builtin
108 #define OTABSL_HAVE_BUILTIN(x) __has_builtin(x)
109 #else
110 #define OTABSL_HAVE_BUILTIN(x) 0
111 #endif
112 
113 #if defined(__is_identifier)
114 #define OTABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x))
115 #else
116 #define OTABSL_INTERNAL_HAS_KEYWORD(x) 0
117 #endif
118 
119 // OTABSL_HAVE_TLS is defined to 1 when __thread should be supported.
120 // We assume __thread is supported on Linux when compiled with Clang or compiled
121 // against libstdc++ with _GLIBCXX_HAVE_TLS defined.
122 #ifdef OTABSL_HAVE_TLS
123 #error OTABSL_HAVE_TLS cannot be directly set
124 #elif defined(__linux__) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
125 #define OTABSL_HAVE_TLS 1
126 #endif
127 
128 // OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
129 //
130 // Checks whether `std::is_trivially_destructible<T>` is supported.
131 //
132 // Notes: All supported compilers using libc++ support this feature, as does
133 // gcc >= 4.8.1 using libstdc++, and Visual Studio.
134 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
135 #error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set
136 #elif defined(_LIBCPP_VERSION) || \
137  (defined(__clang__) && __clang_major__ >= 15) || \
138  (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \
139  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
140  defined(_MSC_VER)
141 #define OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1
142 #endif
143 
144 // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
145 //
146 // Checks whether `std::is_trivially_default_constructible<T>` and
147 // `std::is_trivially_copy_constructible<T>` are supported.
148 
149 // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
150 //
151 // Checks whether `std::is_trivially_copy_assignable<T>` is supported.
152 
153 // Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with
154 // either libc++ or libstdc++, and Visual Studio (but not NVCC).
155 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
156 #error OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set
157 #elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE)
158 #error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set
159 #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \
160  (defined(__clang__) && __clang_major__ >= 15) || \
161  (!defined(__clang__) && defined(__GNUC__) && \
162  (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \
163  (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
164  (defined(_MSC_VER) && !defined(__NVCC__))
165 #define OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1
166 #define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
167 #endif
168 
169 // OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
170 //
171 // Checks whether `std::is_trivially_copyable<T>` is supported.
172 //
173 // Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested.
174 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
175 #error OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
176 #elif defined(__clang__) && (__clang_major__ >= 15)
177 #define OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
178 #endif
179 
180 // OTABSL_HAVE_SOURCE_LOCATION_CURRENT
181 //
182 // Indicates whether `absl::OTABSL_OPTION_NAMESPACE_NAME::SourceLocation::current()` will return useful
183 // information in some contexts.
184 #ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT
185 #if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \
186  OTABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE)
187 #define OTABSL_HAVE_SOURCE_LOCATION_CURRENT 1
188 #endif
189 #endif
190 
191 // OTABSL_HAVE_THREAD_LOCAL
192 //
193 // Checks whether C++11's `thread_local` storage duration specifier is
194 // supported.
195 #ifdef OTABSL_HAVE_THREAD_LOCAL
196 #error OTABSL_HAVE_THREAD_LOCAL cannot be directly set
197 #elif defined(__APPLE__)
198 // Notes:
199 // * Xcode's clang did not support `thread_local` until version 8, and
200 // even then not for all iOS < 9.0.
201 // * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator
202 // targeting iOS 9.x.
203 // * Xcode 10 moves the deployment target check for iOS < 9.0 to link time
204 // making __has_feature unreliable there.
205 //
206 // Otherwise, `__has_feature` is only supported by Clang so it has be inside
207 // `defined(__APPLE__)` check.
208 #if __has_feature(cxx_thread_local) && \
209  !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
210 #define OTABSL_HAVE_THREAD_LOCAL 1
211 #endif
212 #else // !defined(__APPLE__)
213 #define OTABSL_HAVE_THREAD_LOCAL 1
214 #endif
215 
216 // There are platforms for which TLS should not be used even though the compiler
217 // makes it seem like it's supported (Android NDK < r12b for example).
218 // This is primarily because of linker problems and toolchain misconfiguration:
219 // Abseil does not intend to support this indefinitely. Currently, the newest
220 // toolchain that we intend to support that requires this behavior is the
221 // r11 NDK - allowing for a 5 year support window on that means this option
222 // is likely to be removed around June of 2021.
223 // TLS isn't supported until NDK r12b per
224 // https://developer.android.com/ndk/downloads/revision_history.html
225 // Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in
226 // <android/ndk-version.h>. For NDK < r16, users should define these macros,
227 // e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11.
228 #if defined(__ANDROID__) && defined(__clang__)
229 #if __has_include(<android/ndk-version.h>)
230 #include <android/ndk-version.h>
231 #endif // __has_include(<android/ndk-version.h>)
232 #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \
233  defined(__NDK_MINOR__) && \
234  ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))
235 #undef OTABSL_HAVE_TLS
236 #undef OTABSL_HAVE_THREAD_LOCAL
237 #endif
238 #endif // defined(__ANDROID__) && defined(__clang__)
239 
240 // Emscripten doesn't yet support `thread_local` or `__thread`.
241 // https://github.com/emscripten-core/emscripten/issues/3502
242 #if defined(__EMSCRIPTEN__)
243 #undef OTABSL_HAVE_TLS
244 #undef OTABSL_HAVE_THREAD_LOCAL
245 #endif // defined(__EMSCRIPTEN__)
246 
247 // OTABSL_HAVE_INTRINSIC_INT128
248 //
249 // Checks whether the __int128 compiler extension for a 128-bit integral type is
250 // supported.
251 //
252 // Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is
253 // supported, but we avoid using it in certain cases:
254 // * On Clang:
255 // * Building using Clang for Windows, where the Clang runtime library has
256 // 128-bit support only on LP64 architectures, but Windows is LLP64.
257 // * On Nvidia's nvcc:
258 // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions
259 // actually support __int128.
260 #ifdef OTABSL_HAVE_INTRINSIC_INT128
261 #error OTABSL_HAVE_INTRINSIC_INT128 cannot be directly set
262 #elif defined(__SIZEOF_INT128__)
263 #if (defined(__clang__) && !defined(_WIN32)) || \
264  (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
265  (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))
266 #define OTABSL_HAVE_INTRINSIC_INT128 1
267 #elif defined(__CUDACC__)
268 // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a
269 // string explaining that it has been removed starting with CUDA 9. We use
270 // nested #ifs because there is no short-circuiting in the preprocessor.
271 // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined.
272 #if __CUDACC_VER__ >= 70000
273 #define OTABSL_HAVE_INTRINSIC_INT128 1
274 #endif // __CUDACC_VER__ >= 70000
275 #endif // defined(__CUDACC__)
276 #endif // OTABSL_HAVE_INTRINSIC_INT128
277 
278 // OTABSL_HAVE_EXCEPTIONS
279 //
280 // Checks whether the compiler both supports and enables exceptions. Many
281 // compilers support a "no exceptions" mode that disables exceptions.
282 //
283 // Generally, when OTABSL_HAVE_EXCEPTIONS is not defined:
284 //
285 // * Code using `throw` and `try` may not compile.
286 // * The `noexcept` specifier will still compile and behave as normal.
287 // * The `noexcept` operator may still return `false`.
288 //
289 // For further details, consult the compiler's documentation.
290 #ifdef OTABSL_HAVE_EXCEPTIONS
291 #error OTABSL_HAVE_EXCEPTIONS cannot be directly set.
292 
293 #elif defined(__clang__)
294 
295 #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6)
296 // Clang >= 3.6
297 #if __has_feature(cxx_exceptions)
298 #define OTABSL_HAVE_EXCEPTIONS 1
299 #endif // __has_feature(cxx_exceptions)
300 #else
301 // Clang < 3.6
302 // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro
303 #if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions)
304 #define OTABSL_HAVE_EXCEPTIONS 1
305 #endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions)
306 #endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6)
307 
308 // Handle remaining special cases and default to exceptions being supported.
309 #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \
310  !(defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__cpp_exceptions)) && \
311  !(defined(_MSC_VER) && !defined(_CPPUNWIND))
312 #define OTABSL_HAVE_EXCEPTIONS 1
313 #endif
314 
315 // -----------------------------------------------------------------------------
316 // Platform Feature Checks
317 // -----------------------------------------------------------------------------
318 
319 // Currently supported operating systems and associated preprocessor
320 // symbols:
321 //
322 // Linux and Linux-derived __linux__
323 // Android __ANDROID__ (implies __linux__)
324 // Linux (non-Android) __linux__ && !__ANDROID__
325 // Darwin (macOS and iOS) __APPLE__
326 // Akaros (http://akaros.org) __ros__
327 // Windows _WIN32
328 // NaCL __native_client__
329 // AsmJS __asmjs__
330 // WebAssembly __wasm__
331 // Fuchsia __Fuchsia__
332 //
333 // Note that since Android defines both __ANDROID__ and __linux__, one
334 // may probe for either Linux or Android by simply testing for __linux__.
335 
336 // OTABSL_HAVE_MMAP
337 //
338 // Checks whether the platform has an mmap(2) implementation as defined in
339 // POSIX.1-2001.
340 #ifdef OTABSL_HAVE_MMAP
341 #error OTABSL_HAVE_MMAP cannot be directly set
342 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
343  defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
344  defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
345  defined(__ASYLO__)
346 #define OTABSL_HAVE_MMAP 1
347 #endif
348 
349 // OTABSL_HAVE_PTHREAD_GETSCHEDPARAM
350 //
351 // Checks whether the platform implements the pthread_(get|set)schedparam(3)
352 // functions as defined in POSIX.1-2001.
353 #ifdef OTABSL_HAVE_PTHREAD_GETSCHEDPARAM
354 #error OTABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
355 #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
356  defined(__ros__)
357 #define OTABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
358 #endif
359 
360 // OTABSL_HAVE_SCHED_YIELD
361 //
362 // Checks whether the platform implements sched_yield(2) as defined in
363 // POSIX.1-2001.
364 #ifdef OTABSL_HAVE_SCHED_YIELD
365 #error OTABSL_HAVE_SCHED_YIELD cannot be directly set
366 #elif defined(__linux__) || defined(__ros__) || defined(__native_client__)
367 #define OTABSL_HAVE_SCHED_YIELD 1
368 #endif
369 
370 // OTABSL_HAVE_SEMAPHORE_H
371 //
372 // Checks whether the platform supports the <semaphore.h> header and sem_init(3)
373 // family of functions as standardized in POSIX.1-2001.
374 //
375 // Note: While Apple provides <semaphore.h> for both iOS and macOS, it is
376 // explicitly deprecated and will cause build failures if enabled for those
377 // platforms. We side-step the issue by not defining it here for Apple
378 // platforms.
379 #ifdef OTABSL_HAVE_SEMAPHORE_H
380 #error OTABSL_HAVE_SEMAPHORE_H cannot be directly set
381 #elif defined(__linux__) || defined(__ros__)
382 #define OTABSL_HAVE_SEMAPHORE_H 1
383 #endif
384 
385 // OTABSL_HAVE_ALARM
386 //
387 // Checks whether the platform supports the <signal.h> header and alarm(2)
388 // function as standardized in POSIX.1-2001.
389 #ifdef OTABSL_HAVE_ALARM
390 #error OTABSL_HAVE_ALARM cannot be directly set
391 #elif defined(__GOOGLE_GRTE_VERSION__)
392 // feature tests for Google's GRTE
393 #define OTABSL_HAVE_ALARM 1
394 #elif defined(__GLIBC__)
395 // feature test for glibc
396 #define OTABSL_HAVE_ALARM 1
397 #elif defined(_MSC_VER)
398 // feature tests for Microsoft's library
399 #elif defined(__MINGW32__)
400 // mingw32 doesn't provide alarm(2):
401 // https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h
402 // mingw-w64 provides a no-op implementation:
403 // https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c
404 #elif defined(__EMSCRIPTEN__)
405 // emscripten doesn't support signals
406 #elif defined(__Fuchsia__)
407 // Signals don't exist on fuchsia.
408 #elif defined(__native_client__)
409 #else
410 // other standard libraries
411 #define OTABSL_HAVE_ALARM 1
412 #endif
413 
414 // OTABSL_IS_LITTLE_ENDIAN
415 // OTABSL_IS_BIG_ENDIAN
416 //
417 // Checks the endianness of the platform.
418 //
419 // Notes: uses the built in endian macros provided by GCC (since 4.6) and
420 // Clang (since 3.2); see
421 // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html.
422 // Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error.
423 #if defined(OTABSL_IS_BIG_ENDIAN)
424 #error "OTABSL_IS_BIG_ENDIAN cannot be directly set."
425 #endif
426 #if defined(OTABSL_IS_LITTLE_ENDIAN)
427 #error "OTABSL_IS_LITTLE_ENDIAN cannot be directly set."
428 #endif
429 
430 #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
431  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
432 #define OTABSL_IS_LITTLE_ENDIAN 1
433 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
434  __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
435 #define OTABSL_IS_BIG_ENDIAN 1
436 #elif defined(_WIN32)
437 #define OTABSL_IS_LITTLE_ENDIAN 1
438 #else
439 #error "absl endian detection needs to be set up for your compiler"
440 #endif
441 
442 // macOS 10.13 and iOS 10.11 don't let you use <any>, <optional>, or <variant>
443 // even though the headers exist and are publicly noted to work. See
444 // https://github.com/abseil/abseil-cpp/issues/207 and
445 // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes
446 // libc++ spells out the availability requirements in the file
447 // llvm-project/libcxx/include/__config via the #define
448 // _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS.
449 #if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \
450  ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
451  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \
452  (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
453  __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \
454  (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
455  __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \
456  (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \
457  __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000))
458 #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1
459 #else
460 #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0
461 #endif
462 
463 // OTABSL_HAVE_STD_ANY
464 //
465 // Checks whether C++17 std::any is available by checking whether <any> exists.
466 #ifdef OTABSL_HAVE_STD_ANY
467 #error "OTABSL_HAVE_STD_ANY cannot be directly set."
468 #endif
469 
470 #ifdef __has_include
471 #if __has_include(<any>) && __cplusplus >= 201703L && \
472  !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
473 #define OTABSL_HAVE_STD_ANY 1
474 #endif
475 #endif
476 
477 // OTABSL_HAVE_STD_OPTIONAL
478 //
479 // Checks whether C++17 std::optional is available.
480 #ifdef OTABSL_HAVE_STD_OPTIONAL
481 #error "OTABSL_HAVE_STD_OPTIONAL cannot be directly set."
482 #endif
483 
484 #ifdef __has_include
485 #if __has_include(<optional>) && __cplusplus >= 201703L && \
486  !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
487 #define OTABSL_HAVE_STD_OPTIONAL 1
488 #endif
489 #endif
490 
491 // OTABSL_HAVE_STD_VARIANT
492 //
493 // Checks whether C++17 std::variant is available.
494 #ifdef OTABSL_HAVE_STD_VARIANT
495 #error "OTABSL_HAVE_STD_VARIANT cannot be directly set."
496 #endif
497 
498 #ifdef __has_include
499 #if __has_include(<variant>) && __cplusplus >= 201703L && \
500  !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE
501 #define OTABSL_HAVE_STD_VARIANT 1
502 #endif
503 #endif
504 
505 // OTABSL_HAVE_STD_STRING_VIEW
506 //
507 // Checks whether C++17 std::string_view is available.
508 #ifdef OTABSL_HAVE_STD_STRING_VIEW
509 #error "OTABSL_HAVE_STD_STRING_VIEW cannot be directly set."
510 #endif
511 
512 #ifdef __has_include
513 #if __has_include(<string_view>) && __cplusplus >= 201703L
514 #define OTABSL_HAVE_STD_STRING_VIEW 1
515 #endif
516 #endif
517 
518 // For MSVC, `__has_include` is supported in VS 2017 15.3, which is later than
519 // the support for <optional>, <any>, <string_view>, <variant>. So we use
520 // _MSC_VER to check whether we have VS 2017 RTM (when <optional>, <any>,
521 // <string_view>, <variant> is implemented) or higher. Also, `__cplusplus` is
522 // not correctly set by MSVC, so we use `_MSVC_LANG` to check the language
523 // version.
524 // TODO(zhangxy): fix tests before enabling aliasing for `std::any`.
525 #if defined(_MSC_VER) && _MSC_VER >= 1910 && \
526  ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402)
527 // #define OTABSL_HAVE_STD_ANY 1
528 #define OTABSL_HAVE_STD_OPTIONAL 1
529 #define OTABSL_HAVE_STD_VARIANT 1
530 #define OTABSL_HAVE_STD_STRING_VIEW 1
531 #endif
532 
533 // OTABSL_USES_STD_ANY
534 //
535 // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is an alias for std::any.
536 #if !defined(OTABSL_OPTION_USE_STD_ANY)
537 #error options.h is misconfigured.
538 #elif OTABSL_OPTION_USE_STD_ANY == 0 || \
539  (OTABSL_OPTION_USE_STD_ANY == 2 && !defined(OTABSL_HAVE_STD_ANY))
540 #undef OTABSL_USES_STD_ANY
541 #elif OTABSL_OPTION_USE_STD_ANY == 1 || \
542  (OTABSL_OPTION_USE_STD_ANY == 2 && defined(OTABSL_HAVE_STD_ANY))
543 #define OTABSL_USES_STD_ANY 1
544 #else
545 #error options.h is misconfigured.
546 #endif
547 
548 // OTABSL_USES_STD_OPTIONAL
549 //
550 // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is an alias for std::optional.
551 #if !defined(OTABSL_OPTION_USE_STD_OPTIONAL)
552 #error options.h is misconfigured.
553 #elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \
554  (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(OTABSL_HAVE_STD_OPTIONAL))
555 #undef OTABSL_USES_STD_OPTIONAL
556 #elif OTABSL_OPTION_USE_STD_OPTIONAL == 1 || \
557  (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(OTABSL_HAVE_STD_OPTIONAL))
558 #define OTABSL_USES_STD_OPTIONAL 1
559 #else
560 #error options.h is misconfigured.
561 #endif
562 
563 // OTABSL_USES_STD_VARIANT
564 //
565 // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is an alias for std::variant.
566 #if !defined(OTABSL_OPTION_USE_STD_VARIANT)
567 #error options.h is misconfigured.
568 #elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \
569  (OTABSL_OPTION_USE_STD_VARIANT == 2 && !defined(OTABSL_HAVE_STD_VARIANT))
570 #undef OTABSL_USES_STD_VARIANT
571 #elif OTABSL_OPTION_USE_STD_VARIANT == 1 || \
572  (OTABSL_OPTION_USE_STD_VARIANT == 2 && defined(OTABSL_HAVE_STD_VARIANT))
573 #define OTABSL_USES_STD_VARIANT 1
574 #else
575 #error options.h is misconfigured.
576 #endif
577 
578 // OTABSL_USES_STD_STRING_VIEW
579 //
580 // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is an alias for std::string_view.
581 #if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW)
582 #error options.h is misconfigured.
583 #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \
584  (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
585  !defined(OTABSL_HAVE_STD_STRING_VIEW))
586 #undef OTABSL_USES_STD_STRING_VIEW
587 #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
588  (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \
589  defined(OTABSL_HAVE_STD_STRING_VIEW))
590 #define OTABSL_USES_STD_STRING_VIEW 1
591 #else
592 #error options.h is misconfigured.
593 #endif
594 
595 // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION
596 // SEH exception from emplace for variant<SomeStruct> when constructing the
597 // struct can throw. This defeats some of variant_test and
598 // variant_exception_safety_test.
599 #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG)
600 #define OTABSL_INTERNAL_MSVC_2017_DBG_MODE
601 #endif
602 
603 // OTABSL_INTERNAL_MANGLED_NS
604 // OTABSL_INTERNAL_MANGLED_BACKREFERENCE
605 //
606 // Internal macros for building up mangled names in our internal fork of CCTZ.
607 // This implementation detail is only needed and provided for the MSVC build.
608 //
609 // These macros both expand to string literals. OTABSL_INTERNAL_MANGLED_NS is
610 // the mangled spelling of the `absl` namespace, and
611 // OTABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing
612 // the proper count to skip past the CCTZ fork namespace names. (This number
613 // is one larger when there is an inline namespace name to skip.)
614 #if defined(_MSC_VER)
615 #define OTABSL_INTERNAL_MANGLED_NS \
616  OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl"
617 #define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6"
618 #endif
619 
620 #undef OTABSL_INTERNAL_HAS_KEYWORD
621 
622 // OTABSL_DLL
623 //
624 // When building Abseil as a DLL, this macro expands to `__declspec(dllexport)`
625 // so we can annotate symbols appropriately as being exported. When used in
626 // headers consuming a DLL, this macro expands to `__declspec(dllimport)` so
627 // that consumers know the symbol is defined inside the DLL. In all other cases,
628 // the macro expands to nothing.
629 #if defined(_MSC_VER)
630 #if defined(OTABSL_BUILD_DLL)
631 #define OTABSL_DLL __declspec(dllexport)
632 #elif 1
633 #define OTABSL_DLL __declspec(dllimport)
634 #else
635 #define OTABSL_DLL
636 #endif
637 #else
638 #define OTABSL_DLL
639 #endif // defined(_MSC_VER)
640 
641 #endif // OTABSL_BASE_CONFIG_H_
policy_checks.h
options.h