Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build HelloVectors using VS2019 v142 #47

Closed
MarkIngramUK opened this issue Jan 30, 2020 · 7 comments
Closed

Failure to build HelloVectors using VS2019 v142 #47

MarkIngramUK opened this issue Jan 30, 2020 · 7 comments

Comments

@MarkIngramUK
Copy link

I've just cloned the repo, opened the HelloVectors solution file and upgraded to SDK 10.0.18362.0 and toolset v142, and attempted to build. I get the following errors:

1>------ Build started: Project: HelloVectors_win32_cpp, Configuration: Debug x64 ------ 1>pch.cpp 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(980,26): error C2039: 'wait_for': is not a member of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(100): message : see declaration of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(982): message : see reference to class template instantiation 'winrt::impl::consume_Windows_Foundation_IAsyncAction<D>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(9818): message : see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IContextCallback>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(9590): message : see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IServerSecurity>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(9549): message : see reference to class template instantiation 'std::chrono::time_point<winrt::clock,winrt::Windows::Foundation::TimeSpan>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(2117): message : see reference to class template instantiation 'winrt::com_ptr<To>' being compiled 1> with 1> [ 1> To=winrt::impl::IStaticLifetimeCollection 1> ] 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(8969): message : see reference to function template instantiation 'winrt::com_ptr<To> winrt::Windows::Foundation::IUnknown::as<winrt::impl::IStaticLifetimeCollection>(void) const' being compiled 1> with 1> [ 1> To=winrt::impl::IStaticLifetimeCollection 1> ] 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(8966): message : see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IStaticLifetime>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(5215): message : see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IMarshal>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(2460): message : see reference to class template instantiation 'winrt::com_ptr<To>' being compiled 1> with 1> [ 1> To=winrt::impl::ILanguageExceptionErrorInfo2 1> ] 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(4097): message : see reference to function template instantiation 'winrt::com_ptr<To> winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::try_as<winrt::impl::ILanguageExceptionErrorInfo2>(void) noexcept const' being compiled 1> with 1> [ 1> To=winrt::impl::ILanguageExceptionErrorInfo2 1> ] 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\base.h(4179): message : see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>' being compiled 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include\xstring(1743): message : see reference to class template instantiation 'std::basic_string_view<wchar_t,std::char_traits<wchar_t>>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1001,26): error C2039: 'wait_for': is not a member of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(100): message : see declaration of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1003): message : see reference to class template instantiation 'winrt::impl::consume_Windows_Foundation_IAsyncActionWithProgress<D,TProgress>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1035,26): error C2039: 'wait_for': is not a member of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(100): message : see declaration of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1037): message : see reference to class template instantiation 'winrt::impl::consume_Windows_Foundation_IAsyncOperationWithProgress<D,TResult,TProgress>' being compiled 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1054,26): error C2039: 'wait_for': is not a member of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(100): message : see declaration of 'winrt::impl' 1>C:\...\Windows.UI.Composition-Win32-Samples\cpp\HelloVectors\x64\Debug\Generated Files\winrt\impl\Windows.Foundation.0.h(1056): message : see reference to class template instantiation 'winrt::impl::consume_Windows_Foundation_IAsyncOperation<D,TResult>' being compiled

@robmikh
Copy link
Member

robmikh commented Jan 30, 2020

There was an update to C++/WinRT at some point that made it less aggressive at pulling in headers to make compile times better, but it also means being more explicit about including the right headers. It looks like this sample is experiencing that issue.

Here's what I did to get it working on my machine (after upgrading the SDK and toolset like you did):

  • Update both the C++/WinRT and XAML nuget packages
  • In pch.h, add includes for winrt/Windows.Foundation.h and winrt/Windows.Graphics.h

Let me know if that works for you! If so, I'll try to get a pull request issued for it.

@MarkIngramUK
Copy link
Author

This is odd, any winrt/ header will generate these errors. My C++/WinRT extension is up to date. Following a bit of experimentation, I've discovered that disabling conformance mode allows the project to build (i.e. remove /permissive-).

@k15tfu
Copy link

k15tfu commented Jun 16, 2020

Hi! Is there any progress in this issue?

@sileel
Copy link

sileel commented Aug 4, 2020

Disabling conformance did not seem to work for me. For those who run into this in the future, I got similar error message (just the error regarding wait_for) and was able to work around this by inserting the following snippet in pch.h before any other #include statements. It forward declares the wait_for template function defined in winrt/Windows.Foundation.h. winrt/base.h is here because it contains definition of Timespan.

#include "winrt/base.h"
namespace winrt::impl
{
    template <typename Async>
    auto wait_for(Async const& async, Windows::Foundation::TimeSpan const& timeout);
}

@trueqbit
Copy link

The problem is that \Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\Windows.Foundation.h is the file that defines winrt::impl::wait_for, but also the one that includes "winrt/impl/Windows.Foundation.2.h" at the beginning, which in turn needs winrt::impl::wait_for.
This circular dependency should be properly dealt with...

@smourier
Copy link

smourier commented Feb 8, 2021

For what it's worth, one solution is to simply manually add the latest (Version 2+) Microsoft.Windows.CppWinRT (https://www.nuget.org/packages/Microsoft.Windows.CppWinRT/) package to the project (by default, it's not there). This will modify the .csproj and then everything should compile fine.

@Breit
Copy link

Breit commented May 14, 2022

Adding '/Zc:twoPhase-' might also help.

@juan- juan- closed this as completed Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants