The latest versions of Visual Studio 2019 have support for clang-tidy static analysis. The problem is that clang-tidy relies on clang to compile the source for the actual analysis and the generated winrt/base.h cannot be compiled with clang due to a call to co_await():
template <typename T>
auto get_awaiter(T&& value) noexcept -> decltype(static_cast<T&&>(value).operator co_await())
{
return static_cast<T&&>(value).operator co_await();
}
template <typename T>
auto get_awaiter(T&& value) noexcept -> decltype(operator co_await(static_cast<T&&>(value)))
{
return operator co_await(static_cast<T&&>(value));
}
winrt/base.h(8200,87): error G58EA42A4: unknown type name 'co_await' [clang-diagnostic-error]
winrt/base.h(8206,63): error G58EA42A4: unknown type name 'co_await' [clang-diagnostic-error]
As this causes clang-tidy to generate a "clang-diagnostic-error" error and not just a warning the MSBuild build of the project will fail. Using clang-tidy with WinRT is thus not possible at the moment.
Used Visual Studio version: 2019 16.6.0 Preview 1.0
Used Nuget WinRT: 2.0.200316.3
Workaround:
Wrapping these 2 functions in #ifndef __clang__ / #endif (as is done in other places in base.h) solves the problem for clang-tidy in my case. As base.h can be regenerated and is often done, this is not a good long-term solution.
The latest versions of Visual Studio 2019 have support for clang-tidy static analysis. The problem is that clang-tidy relies on clang to compile the source for the actual analysis and the generated winrt/base.h cannot be compiled with clang due to a call to co_await():
As this causes clang-tidy to generate a "clang-diagnostic-error" error and not just a warning the MSBuild build of the project will fail. Using clang-tidy with WinRT is thus not possible at the moment.
Used Visual Studio version: 2019 16.6.0 Preview 1.0
Used Nuget WinRT: 2.0.200316.3
Workaround:
Wrapping these 2 functions in #ifndef __clang__ / #endif (as is done in other places in base.h) solves the problem for clang-tidy in my case. As base.h can be regenerated and is often done, this is not a good long-term solution.