зеркало из https://github.com/microsoft/cppwinrt.git
Make `guid` `constexpr` on Clang and improve error reporting (#1191)
This commit is contained in:
Родитель
64cdc7c6d8
Коммит
e7b690382e
|
@ -25,8 +25,11 @@
|
|||
-->
|
||||
|
||||
<PropertyGroup Condition="'$(Clang)'=='1'">
|
||||
<CLToolExe>clang-cl.exe</CLToolExe>
|
||||
<CLToolPath>C:\Program Files\LLVM\bin</CLToolPath>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<!-- The experimental coroutines aren't supported under Clang -->
|
||||
<CppWinRTLanguageStandard>20</CppWinRTLanguageStandard>
|
||||
<!-- Disable vcpkg autolink because it's not compatible with lld-link -->
|
||||
<VcpkgAutoLink>false</VcpkgAutoLink>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -51,7 +54,7 @@
|
|||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<AdditionalOptions>/bigobj</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(CppWinRTLanguageStandard)'==''">/await %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Clang)'=='1'">-Wno-unused-command-line-argument -fno-delayed-template-parsing -Xclang -fcoroutines-ts -mcx16</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Clang)'=='1'">-Wno-unused-command-line-argument -fno-delayed-template-parsing -mcx16</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>onecore.lib</AdditionalDependencies>
|
||||
|
|
|
@ -105,10 +105,9 @@
|
|||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;WIN32;_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
|
@ -131,11 +130,10 @@
|
|||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -156,11 +154,10 @@
|
|||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;_DEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -183,11 +180,10 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;WIN32;NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -213,11 +209,10 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -243,11 +238,10 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VSDEBUGENG_USE_CPP11_SCOPED_ENUMS;NDEBUG;VISUALIZER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);..\cppwinrt;..\strings;$(DIASDKInc);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalOptions>/await</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
@ -458,12 +458,8 @@ namespace winrt::impl
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
#ifdef __clang__
|
||||
inline static const auto name_v
|
||||
#else
|
||||
#pragma warning(suppress: 4307)
|
||||
inline constexpr auto name_v
|
||||
#endif
|
||||
{
|
||||
combine
|
||||
(
|
||||
|
|
|
@ -117,17 +117,22 @@ namespace winrt::impl
|
|||
static constexpr auto data{ category_signature<category_t<T>, T>::data };
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
#if defined(__clang__)
|
||||
template <typename T>
|
||||
struct classic_com_guid
|
||||
{
|
||||
#if __has_declspec_attribute(uuid) && defined(WINRT_IMPL_IUNKNOWN_DEFINED)
|
||||
inline const guid guid_v{ __uuidof(T) };
|
||||
static constexpr guid value{ __uuidof(T) };
|
||||
#else
|
||||
inline constexpr guid guid_v{};
|
||||
static_assert(std::is_void_v<T> /* dependent_false */, "To use classic COM interfaces, you must compile with -fms-extensions and include <unknwn.h> before including C++/WinRT headers.");
|
||||
#endif
|
||||
#elif defined(_MSC_VER) && defined(WINRT_IMPL_IUNKNOWN_DEFINED)
|
||||
inline constexpr guid guid_v{ __uuidof(T) };
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline constexpr guid guid_v = classic_com_guid<T>::value;
|
||||
#else
|
||||
inline constexpr guid guid_v{};
|
||||
template <typename T>
|
||||
inline constexpr guid guid_v{ __uuidof(T) };
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -8,9 +8,5 @@ TEST_CASE("generic_types")
|
|||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.Uri", Uri);
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.PropertyType", PropertyType);
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.Point", Point);
|
||||
|
||||
// Clang 9 doesn't think this is a constant expression.
|
||||
#ifndef __clang__
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.IStringable", IStringable);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -8,9 +8,5 @@ TEST_CASE("generic_types")
|
|||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.Uri", Uri);
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.PropertyType", PropertyType);
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.Point", Point);
|
||||
|
||||
// Clang 9 doesn't think this is a constant expression.
|
||||
#ifndef __clang__
|
||||
REQUIRE_EQUAL_NAME(L"Windows.Foundation.IStringable", IStringable);
|
||||
#endif
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче