JuliaInterop / libcxxwrap-julia

C++ library for backing CxxWrap.jl
Other
85 stars 43 forks source link

Compile errors VC++ 2017: array_iterator_base won't compile #29

Closed robmosys closed 4 years ago

robmosys commented 5 years ago

Compiling the library from master (commit 3818cbe8), with CMake, with julia 1.0.2 and VC++2017 15.9.4 get the various errors, including the following when building the types example.

D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xmemory(217): error C2678: binary '*': no operator found which takes a left-hand operand of type 'const _Iter' (or there is no acceptable conversion)

This can be fixed by adding the following operator definition to the array_iterator_base class:

  auto operator*() const -> decltype(ValueExtractor<PointedT, CppT>()(m_ptr))
  {
      return ValueExtractor<PointedT, CppT>()(m_ptr);
  }

Other projects have had similar issues, and fixed by adding the operator overload for const objects, e.g.: https://github.com/tensorflow/tensorflow/issues/15925 I have only looked into this casually so far and have done no significant testing, but can successfully compile with this additional function.

I have attached the full VC++ compile log for the types example here: types.log

Finally, with VC++2019 this error does not occur.

barche commented 5 years ago

OK, the latest master should compile on VC2019, I have also updated the build instructions in the libcxxwrap-julia README.