boostorg / yap

A C++14-and-later expression template library
https://boostorg.github.io/yap
Boost Software License 1.0
108 stars 28 forks source link

VS2017 support #88

Closed Kojoley closed 6 years ago

Kojoley commented 6 years ago

With these fixes/workarounds the library is usable on msvc-14.1 and all tests pass.

tzlaine commented 6 years ago

Any idea why the Appveyor build still fails?

pdimov commented 6 years ago

The first error I see is

LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc141-mt-gd-x64-1_68.lib' 

Not sure how it's supposed to work.

Kojoley commented 6 years ago
c:\projects\yap\example\lazy_vector.cpp(88): error C3779: 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []': a function that returns 'auto' cannot be used before it is defined [C:\projects\yap\build\example\lazy_vector.vcxproj]
  c:\projects\yap\example\lazy_vector.cpp(44): note: see declaration of 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []'
  c:\projects\yap\example\lazy_vector.cpp(103): note: see reference to function template instantiation 'lazy_vector &lazy_vector::operator +=<boost::yap::expr_kind::minus,tuple_type>(const lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type> &)' being compiled
c:\projects\yap\example\lazy_vector.cpp(88): error C2088: '[': illegal for struct 
  c:\projects\yap\example\lazy_vector.cpp(88): error C3779: 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []': a function that returns 'auto' cannot be used before it is defined [C:\projects\yap\build\example\lazy_vector.vcxproj]
  c:\projects\yap\example\lazy_vector.cpp(88): error C2088: '[': illegal for struct [C:\projects\yap\build\example\lazy_vector.vcxproj]
"C:\projects\yap\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\projects\yap\build\perf\lazy_vector_perf.vcxproj" (default target) (27) ->
  c:\projects\yap\perf\lazy_vector_perf.cpp(90): error C3779: 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []': a function that returns 'auto' cannot be used before it is defined [C:\projects\yap\build\perf\lazy_vector_perf.vcxproj]
  c:\projects\yap\perf\lazy_vector_perf.cpp(90): error C2088: '[': illegal for struct [C:\projects\yap\build\perf\lazy_vector_perf.vcxproj]

I have only run tests under test folder with b2 myself.

pdimov commented 6 years ago

Later on, there's this:

  lazy_vector.cpp
CL : warning : the native Microsoft compiler is not supported due to lack of proper C++14 support. [C:\projects\yap\build\example\lazy_vector.vcxproj]
CL : warning : Your compiler doesn't provide C++14 or higher capabilities. Try adding the compiler flag '-std=c++14' or '-std=c++1y'. [C:\projects\yap\build\example\lazy_vector.vcxproj]
c:\projects\yap\example\lazy_vector.cpp(88): error C3779: 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []': a function that returns 'auto' cannot be used before it is defined [C:\projects\yap\build\example\lazy_vector.vcxproj]
  c:\projects\yap\example\lazy_vector.cpp(44): note: see declaration of 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []'
  c:\projects\yap\example\lazy_vector.cpp(103): note: see reference to function template instantiation 'lazy_vector &lazy_vector::operator +=<boost::yap::expr_kind::minus,tuple_type>(const lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type> &)' being compiled
c:\projects\yap\example\lazy_vector.cpp(88): error C2088: '[': illegal for struct [C:\projects\yap\build\example\lazy_vector.vcxproj]
Done Building Project "C:\projects\yap\build\example\lazy_vector.vcxproj" (default targets) -- FAILED.

No idea about this one either, but I wonder whether the 1.68 Hana works on 2017. There are VC-specific fixes on its develop branch.

Kojoley commented 6 years ago

Tested it locally with the latest VS and got the same error

1>main.cpp(119): error C3779: 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []': a function that returns 'auto' cannot be used before it is defined
1>main.cpp(74): note: see declaration of 'lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type>::operator []'
1>main.cpp(143): note: see reference to function template instantiation 'lazy_vector &lazy_vector::operator +=<boost::yap::expr_kind::minus,tuple_type>(const lazy_vector_expr<boost::yap::expr_kind::minus,tuple_type> &)' being compiled
1>main.cpp(119): error C2088: '[': illegal for struct
tzlaine commented 6 years ago

Yeah, these look to me like the compiler is not applying the full-fledged rules for deduction.

The Boost.Serialization bit looks like autolinking, possibly from my use of the Boost.Test headers. I'm certainly not linking it in on purpose.

Kojoley commented 6 years ago

Yeah, these look to me like the compiler is not applying the full-fledged rules for deduction.

If I move definition into the struct it compiles. A simplified case with auto definition out of class works so I do not know what is broken in MSVC, but I am not surprised...

The Boost.Serialization bit looks like autolinking, possibly from my use of the Boost.Test headers. I'm certainly not linking it in on purpose.

Serialization links because of https://github.com/boostorg/yap/blob/b9d6d347dd74b85efe28acf9f57a3544712b22a1/example/autodiff_library/autodiff.h#L14