leapmotion / autowiring

A C++ Inversion of Control Framework
http://autowiring.io/
Apache License 2.0
148 stars 17 forks source link

Failed to build due to the error C2039, C2878, C2065, C2146, C3083 #1057

Closed shanshan0309 closed 6 years ago

shanshan0309 commented 6 years ago

We build with Autowiring with VS2017 (version 15.5.7) on Windows. But it failed with the error C2039, C2878, C2065, C2146, C3083. This issue can be reproduced from master revision fc48e3b. Could you please help take a look at this? Thanks!

Repro steps:

  1. Open VS2017 x86 Native tools command tool
  2. git clone https://github.com/leapmotion/autowiring d:\Autowiring\src
  3. cd D:\Autowiring
  4. mkdir build_x86 && pushd build_x86
  5. cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=10.0.16299.0 ..\src\
  6. msbuild /m /p:Configuration=Release;Platform=Win32 Autowiring.sln /t:Rebuild

Error info: The whole log file please see attachment. log_x86_build.log Build FAILED. "D:\Autowiring\build_x86\Autowiring.sln" (Rebuild target) (1) -> "D:\Autowiring\build_x86\ALL_BUILD.vcxproj.metaproj" (Rebuild target) (2) -> "D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj.metaproj" (Rebuild target) (10) -> "D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj" (Rebuild target) (21) -> (ClCompile target) -> D:\Autowiring\src\src.\autowiring/C++11/filesystem.h(9): error C2039: 'filesystem': is not a member of 'std' [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src.\autowiring/C++11/filesystem.h(9): error C2878: 'filesystem': a namespace or class of this name does not exist [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(16): error C3083: 'filesystem': the symbol to the left of a '::' must be a type [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(16): error C2039: 'path': is not a member of 'std' [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(16): error C2065: 'path': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(16): error C2146: syntax error: missing ';' before identifier 'p' [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(16): error C2065: 'p': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C3083: 'filesystem': the symbol to the left of a '::' must be a type [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C2039: 'path': is not a member of 'std' [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C2065: 'path': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C2065: 'p': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C2228: left of '.extension' must have class/struct/union [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(17): error C2512: 'testing::AssertionResult': no appropriate default constructor available [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C3083: 'filesystem': the symbol to the left of a '::' must be a type [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C2039: 'path': is not a member of 'std' [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C2065: 'path': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C2065: 'p': undeclared identifier [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C2228: left of '.filename' must have class/struct/union [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj] D:\Autowiring\src\src\autowiring\test\FileSystemHeaderTest.cpp(18): error C2512: 'testing::AssertionResult': no appropriate default constructor available [D:\Autowiring\build_x86\src\autowiring\test\AutowiringTest.vcxproj]

jdonald commented 6 years ago

@shanshan0309 is this actually version 15.5.7? Just wondering because we heard the same in #1051 for an issue that would not reproduce on 15.5.7, and it turned out to be an as-of-yet unreleased compiler build.

Using ..\src\ as the source directory seems odd? This didn't work for @gittyupagain. Should be the root of autowiring source i.e. .. but hopefully this is largely unrelated to the compiler error at hand.

Lines 7 through 9 look like so:

  #if _MSC_VER >= 1914 && _MSVC_LANG >= 201402L
    // VS 2017 15.7 Preview 2 or newer with /std:c++17
    namespace awfsnamespace = std::filesystem;

which indicates that _MSVC_LANG may have had its value raised, perhaps to 201703L or 201704L. If so, @CaseyCarter could you tell us exactly what value it will have?

We've looked over this blog post and can consider adding /Zc:__cplusplus but would need to find a way to do that without breaking the autowiring build on earlier MSVC versions.

BillyONeal commented 6 years ago

@shanshan0309 This looks like you tested the new backend without getting the header updates to <filesystem>.

shanshan0309 commented 6 years ago

@jdonald and @BillyONeal. Thanks all for looking into this issue. When I raised the value of _MSVC_LANG to 201704L and Autowiring will build successfully. Thanks!

CaseyCarter commented 6 years ago

201402 is the __cplusplus value for C++14. C++17's value is 201703. So the test you're performing:

  #if _MSC_VER >= 1914 && _MSVC_LANG >= 201402L
    // VS 2017 15.7 Preview 2 or newer with /std:c++17

Is actually checking for VS 15.7 with at least /std:c++14.

shanshan0309 commented 6 years ago

Hi All, This issue seems not to be solved. For the code in filesystem.h:

if !defined(_MSC_VER) || _MSC_VER < 1914 || _MSVC_LANG < 201402L

This is also need to change as 201403L. We are no longer hit this issue when we changed to 201403L. Thanks!

CaseyCarter commented 6 years ago

201703L would make more sense for consistency with the check on line 7.