diff --git a/include/proxy/v4/detail/compatibility_check.h b/include/proxy/v4/detail/compatibility_check.h new file mode 100644 index 0000000..0c06083 --- /dev/null +++ b/include/proxy/v4/detail/compatibility_check.h @@ -0,0 +1,28 @@ +// Copyright (c) 2022-2026 Microsoft Corporation. +// Copyright (c) 2026-Present Next Gen C++ Foundation. +// Licensed under the MIT License. + +#ifndef MSFT_PROXY_V4_DETAIL_COMPATIBILITY_CHECK_H_ +#define MSFT_PROXY_V4_DETAIL_COMPATIBILITY_CHECK_H_ + +#if (defined(_MSVC_LANG) ? _MSVC_LANG : __cplusplus) < 202002L +#error "Proxy requires C++20 or later." +#endif + +// clang-cl miscalculates the layout of an empty [[msvc::no_unique_address]] +// member in a base class (llvm/llvm-project#143245), corrupting pro::proxy. +#if __has_cpp_attribute(msvc::no_unique_address) +namespace pro::inline v4::detail::compatibility_check { +struct empty {}; +struct base { + [[msvc::no_unique_address]] empty value; +}; +struct derived : base { + char dummy; +}; +static_assert(sizeof(derived) == sizeof(char), + "[[msvc::no_unique_address]] is broken"); +} // namespace pro::inline v4::detail::compatibility_check +#endif + +#endif // MSFT_PROXY_V4_DETAIL_COMPATIBILITY_CHECK_H_ diff --git a/include/proxy/v4/proxy.h b/include/proxy/v4/proxy.h index 84735c4..848c6ef 100644 --- a/include/proxy/v4/proxy.h +++ b/include/proxy/v4/proxy.h @@ -5,10 +5,11 @@ #ifndef MSFT_PROXY_V4_PROXY_H_ #define MSFT_PROXY_V4_PROXY_H_ -#include "detail/core.h" // IWYU pragma: export -#include "detail/dispatch.h" // IWYU pragma: export -#include "detail/facade_creation.h" // IWYU pragma: export -#include "detail/proxy_creation.h" // IWYU pragma: export -#include "detail/skills.h" // IWYU pragma: export +#include "detail/compatibility_check.h" // IWYU pragma: keep +#include "detail/core.h" // IWYU pragma: export +#include "detail/dispatch.h" // IWYU pragma: export +#include "detail/facade_creation.h" // IWYU pragma: export +#include "detail/proxy_creation.h" // IWYU pragma: export +#include "detail/skills.h" // IWYU pragma: export #endif // MSFT_PROXY_V4_PROXY_H_