106 lines · c
1//===----------------------------------------------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H10#define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H11 12// This header is force-included when running the libc++ tests against the13// MSVC standard library.14 15#ifndef _LIBCXX_IN_DEVCRT16// Silence warnings about CRT machinery.17# define _CRT_SECURE_NO_WARNINGS 118 19// Avoid assertion dialogs.20# define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()21 22// Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)23# define _CRT_DECLARE_NONSTDC_NAMES 124 25// Silence warnings about POSIX function names.26# define _CRT_NONSTDC_NO_WARNINGS 127 28// Avoid Windows.h macroizing min() and max().29# define NOMINMAX 130#endif // _LIBCXX_IN_DEVCRT31 32#include <crtdbg.h>33#include <stdlib.h>34 35#if defined(_LIBCPP_VERSION)36# error This header may not be used when targeting libc++37#endif38 39#ifndef _LIBCXX_IN_DEVCRT40struct AssertionDialogAvoider {41 AssertionDialogAvoider() {42 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);43 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);44 45 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);46 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);47 }48};49 50const AssertionDialogAvoider assertion_dialog_avoider{};51#endif // _LIBCXX_IN_DEVCRT52 53// MSVC frontend only configurations54#if !defined(__clang__)55// Simulate feature-test macros.56# define __has_feature(X) _MSVC_HAS_FEATURE_##X57# define _MSVC_HAS_FEATURE_cxx_exceptions 158# define _MSVC_HAS_FEATURE_cxx_rtti 159# define _MSVC_HAS_FEATURE_address_sanitizer 060# define _MSVC_HAS_FEATURE_hwaddress_sanitizer 061# define _MSVC_HAS_FEATURE_memory_sanitizer 062# define _MSVC_HAS_FEATURE_thread_sanitizer 063 64# define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_##X65# define _MSVC_HAS_ATTRIBUTE_vector_size 066 67// Silence compiler warnings.68# pragma warning(disable : 4180) // qualifier applied to function type has no meaning; ignored69# pragma warning(disable : 4324) // structure was padded due to alignment specifier70# pragma warning(disable : 4702) // unreachable code71# pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations.72#endif // !defined(__clang__)73 74#ifndef _LIBCXX_IN_DEVCRT75// atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.76# define _ENABLE_ATOMIC_ALIGNMENT_FIX77 78// Restore features that are removed in C++20.79# define _HAS_FEATURES_REMOVED_IN_CXX20 180 81// Silence warnings about the unspecified complex<non-floating-point>82# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING83 84// Silence warnings about features that are deprecated in non-default language modes.85# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS86# define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS87# define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS88#endif // _LIBCXX_IN_DEVCRT89 90#include <version>91 92#if _HAS_CXX2393# define TEST_STD_VER 2394#elif _HAS_CXX2095# define TEST_STD_VER 2096#elif _HAS_CXX1797# define TEST_STD_VER 1798#else99# define TEST_STD_VER 14100#endif101 102#define TEST_SHORT_WCHAR103#define TEST_ABI_MICROSOFT104 105#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H106