[libcxx-commits] [libcxx] [libc++][test] Update `msvc_stdlib_force_include.h` (PR #74266)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 4 02:56:03 PST 2023
================
@@ -13,98 +13,106 @@
// MSVC standard library.
#ifndef _LIBCXX_IN_DEVCRT
- // Silence warnings about CRT machinery.
- #define _CRT_SECURE_NO_WARNINGS 1
+// Silence warnings about CRT machinery.
+# define _CRT_SECURE_NO_WARNINGS 1
- // Avoid assertion dialogs.
- #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+// Avoid assertion dialogs.
+# define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+
+// Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)
+# define _CRT_DECLARE_NONSTDC_NAMES 1
+
+// Silence warnings about POSIX function names.
+# define _CRT_NONSTDC_NO_WARNINGS 1
+
+// Avoid Windows.h macroizing min() and max().
+# define NOMINMAX 1
#endif // _LIBCXX_IN_DEVCRT
#include <crtdbg.h>
#include <stdlib.h>
#if defined(_LIBCPP_VERSION)
- #error This header may not be used when targeting libc++
+# error This header may not be used when targeting libc++
#endif
#ifndef _LIBCXX_IN_DEVCRT
struct AssertionDialogAvoider {
- AssertionDialogAvoider() {
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ AssertionDialogAvoider() {
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- }
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ }
};
const AssertionDialogAvoider assertion_dialog_avoider{};
#endif // _LIBCXX_IN_DEVCRT
// MSVC frontend only configurations
#if !defined(__clang__)
- // Simulate feature-test macros.
- #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
- #define _MSVC_HAS_FEATURE_cxx_exceptions 1
- #define _MSVC_HAS_FEATURE_cxx_rtti 1
- #define _MSVC_HAS_FEATURE_address_sanitizer 0
- #define _MSVC_HAS_FEATURE_memory_sanitizer 0
- #define _MSVC_HAS_FEATURE_thread_sanitizer 0
-
- #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
- #define _MSVC_HAS_ATTRIBUTE_vector_size 0
-
- // Silence compiler warnings.
- #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
- #pragma warning(disable: 4324) // structure was padded due to alignment specifier
- #pragma warning(disable: 4521) // multiple copy constructors specified
- #pragma warning(disable: 4702) // unreachable code
- #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
-#endif // !defined(__clang__)
+// Simulate feature-test macros.
+# define __has_feature(X) _MSVC_HAS_FEATURE_##X
+# define _MSVC_HAS_FEATURE_cxx_exceptions 1
+# define _MSVC_HAS_FEATURE_cxx_rtti 1
+# define _MSVC_HAS_FEATURE_address_sanitizer 0
+# define _MSVC_HAS_FEATURE_hwaddress_sanitizer 0
+# define _MSVC_HAS_FEATURE_memory_sanitizer 0
+# define _MSVC_HAS_FEATURE_thread_sanitizer 0
+
+# define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_##X
+# define _MSVC_HAS_ATTRIBUTE_vector_size 0
+
+# define __has_builtin(X) _MSVC_HAS_BUILTIN_##X
----------------
philnik777 wrote:
I suspect that we don't actually need this check anymore. `__builtin_source_location` has been added in Clang 15, and I don't think we have any compiler that is based on something earlier anymore. Would you mind trying to remove it and checking whether the CI passes on that?
https://github.com/llvm/llvm-project/pull/74266
More information about the libcxx-commits
mailing list