microsoft / microsoft/wil

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

Open
#25 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

compiler-support msvc
Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal VS2017 15.9.2 console reproduction using the Microsoft.Windows.ImplementationLibrary NuGet package and #include <wil/resource.h>. Inspect wil/wistd_type_traits.h and wil/result_macros.h around the reported lines, comparing C++14 and C++17 builds. Done means the supplied C++17 example compiles without the reported errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.