1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
10 #define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
12 // This header is force-included when running the libc++ tests against the
13 // MSVC standard library.
15 #ifndef _LIBCXX_IN_DEVCRT
16 // Silence warnings about CRT machinery.
17 # define _CRT_SECURE_NO_WARNINGS 1
19 // Avoid assertion dialogs.
20 # define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
22 // Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)
23 # define _CRT_DECLARE_NONSTDC_NAMES 1
25 // Silence warnings about POSIX function names.
26 # define _CRT_NONSTDC_NO_WARNINGS 1
28 // Avoid Windows.h macroizing min() and max().
30 #endif // _LIBCXX_IN_DEVCRT
35 #if defined(_LIBCPP_VERSION)
36 # error This header may not be used when targeting libc++
39 #ifndef _LIBCXX_IN_DEVCRT
40 struct AssertionDialogAvoider
{
41 AssertionDialogAvoider() {
42 _CrtSetReportMode(_CRT_ASSERT
, _CRTDBG_MODE_FILE
);
43 _CrtSetReportFile(_CRT_ASSERT
, _CRTDBG_FILE_STDERR
);
45 _CrtSetReportMode(_CRT_ERROR
, _CRTDBG_MODE_FILE
);
46 _CrtSetReportFile(_CRT_ERROR
, _CRTDBG_FILE_STDERR
);
50 const AssertionDialogAvoider assertion_dialog_avoider
{};
51 #endif // _LIBCXX_IN_DEVCRT
53 // MSVC frontend only configurations
54 #if !defined(__clang__)
55 // Simulate feature-test macros.
56 # define __has_feature(X) _MSVC_HAS_FEATURE_##X
57 # define _MSVC_HAS_FEATURE_cxx_exceptions 1
58 # define _MSVC_HAS_FEATURE_cxx_rtti 1
59 # define _MSVC_HAS_FEATURE_address_sanitizer 0
60 # define _MSVC_HAS_FEATURE_hwaddress_sanitizer 0
61 # define _MSVC_HAS_FEATURE_memory_sanitizer 0
62 # define _MSVC_HAS_FEATURE_thread_sanitizer 0
64 # define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_##X
65 # define _MSVC_HAS_ATTRIBUTE_vector_size 0
67 // Silence compiler warnings.
68 # pragma warning(disable : 4180) // qualifier applied to function type has no meaning; ignored
69 # pragma warning(disable : 4324) // structure was padded due to alignment specifier
70 # pragma warning(disable : 4521) // multiple copy constructors specified
71 # pragma warning(disable : 4702) // unreachable code
72 # pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations.
73 #endif // !defined(__clang__)
75 #ifndef _LIBCXX_IN_DEVCRT
76 // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
77 # define _ENABLE_ATOMIC_ALIGNMENT_FIX
79 // Restore features that are removed in C++20.
80 # define _HAS_FEATURES_REMOVED_IN_CXX20 1
82 // Silence warnings about the unspecified complex<non-floating-point>
83 # define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
85 // Silence warnings about features that are deprecated in non-default language modes.
86 # define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
87 # define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS
88 # define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
89 #endif // _LIBCXX_IN_DEVCRT
94 # define TEST_STD_VER 99
96 # define TEST_STD_VER 20
98 # define TEST_STD_VER 17
100 # define TEST_STD_VER 14
103 #define TEST_SHORT_WCHAR
105 #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
108 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
109 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
110 # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
111 #else // ^^^ clang / MSVC vvv
112 # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
113 __pragma(warning(push)) __pragma(warning(disable : 4996)) __pragma(warning(disable : 5215))
114 # define _LIBCPP_SUPPRESS_DEPRECATED_POP __pragma(warning(pop))
117 #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H