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

Unable to use the library within a C++17 project #25

Open
ehorrent opened this issue May 10, 2019 · 2 comments
Open

Unable to use the library within a C++17 project #25

ehorrent opened this issue May 10, 2019 · 2 comments
Labels
compiler-support msvc Bugs or behavioral issues that are specific to MSVC

Comments

@ehorrent
Copy link

ehorrent commented May 10, 2019

There is several compilation errors when trying to use the library within a C++17 project (I use the NuGet package and have no problem with std versions <= 14).
My version of VS2017 is 15.9.2.

Reproduction steps:
Create an empty console application, install Nuget Microsoft.Windows.ImplementationLibrary v1.0.190430.13 and just update your main to include wil/resources.h :

#include <windows.h>
#include <wil/resource.h>
int main()
{
}

Here are the error messages I get:

include\wil\wistd_type_traits.h(1011): error C2275: '_Tp': illegal use of this type as an expression
include\wil\wistd_type_traits.h(1010): note: see declaration of '_Tp'
include\wil\wistd_type_traits.h(1011): note: see reference to class template instantiation 'wistd::is_aggregate<_Tp>' being compiled
include\wil\wistd_type_traits.h(1011): error C3861: '__is_aggregate': identifier not found
include\wil\wistd_type_traits.h(1011): error C2975: '__v': invalid template argument for 'wistd::integral_constant', expected compile-time constant expression
include\wil\wistd_type_traits.h(113): note: see declaration of '__v'
include\wil\result_macros.h(2168): error C2440: '=': cannot convert from 'void (__cdecl *)(bool,const wil::FailureInfo &)' to 'void (__cdecl *)(bool,const wil::FailureInfo &) noexcept'
include\wil\result_macros.h(2168): note: Conversion to a function with more restrictive exception specification requires reinterpret_cast
include\wil\result_macros.h(2178): error C2440: '=': cannot convert from 'void (__cdecl *)(const wil::FailureInfo &)' to 'void (__cdecl *)(const wil::FailureInfo &) noexcept'
include\wil\result_macros.h(2178): note: Conversion to a function with more restrictive exception specification requires reinterpret_cast
include\wil\result_macros.h(2191): error C2440: '=': cannot convert from 'void (__cdecl *)(wil::FailureInfo *,PWSTR,::size_t)' to 'void (__cdecl *)(wil::FailureInfo *,PWSTR,::size_t) noexcept'
include\wil\result_macros.h(2191): note: Conversion to a function with more restrictive exception specification requires reinterpret_cast
include\wil\result_macros.h(2201): error C2440: '=': cannot convert from 'HRESULT (__cdecl *)(void)' to 'HRESULT (__cdecl *)(void) noexcept'
include\wil\result_macros.h(2201): note: Conversion to a function with more restrictive exception specification requires reinterpret_cast
include\wil\result_macros.h(2212): error C2440: '=': cannot convert from 'void (__cdecl *)(const wil::FailureInfo &)' to 'void (__cdecl *)(const wil::FailureInfo &) noexcept'
include\wil\result_macros.h(2212): note: Conversion to a function with more restrictive exception specification requires reinterpret_cast

Some messages seem related to this compiler issue: c++ compiler bug with decltype functions that have noexcept.

@dunhor
Copy link
Member

dunhor commented May 10, 2019

Sounds like there's two issues here.

The first is that it seems like __is_aggregate is not available in some older versions of MSVC that support /std:c++17 (though this seems to suggest that it should be available in your version). The first is easily worked around by defining __WI_LIBCPP_HAS_NO_IS_AGGREGATE. We should ideally be conditionally defining this based off _MSC_VER or _MSC_FULL_VER, but sadly these things aren't well documented, so there's some amount of whack-a-mole that needs to get done.

The second is the bug that you link that seems to have been fixed in later versions. I've ironically had to add a workaround for function pointers for C++14 since behavior was broken in VS2019. This workaround can be leveraged to have WI_PFN_NOEXCEPT defined to nothing for earlier versions of MSVC.

I'd say feel free to submit a PR that conditionalizes the above on your MSVC version. If someone comes along with a later version of VS that's still broken, we'll have to bump the version numbers again, but I don't believe that there's any better option, unfortunately.

@icnocop
Copy link

icnocop commented Mar 24, 2023

As a work-around, downgrade the NuGet package Microsoft.Windows.ImplementationLibrary to 1.0.210803.1

hiroyuki-komatsu pushed a commit to google/mozc that referenced this issue Apr 24, 2023
- Add the WIL directory to the include path
- Define __WI_LIBCPP_HAS_NO_IS_AGGREGATE in VC++ 2017 as WIL doesn't build as it is  microsoft/wil#25

PiperOrigin-RevId: 526162487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-support msvc Bugs or behavioral issues that are specific to MSVC
Projects
None yet
Development

No branches or pull requests

3 participants