0

After downloading this https://github.com/pybind/pybind11/archive/v2.2.3.zip and creating a simple cpp file:

#include <pybind11/pybind11.h>

int add(int i, int j) { return i + j; }

PYBIND11_MODULE(example, m) {
    m.doc() = "pybind11 example plugin"; // optional module docstring
    m.def("add", &add, "A function which adds two numbers");
}

with

enter image description here

I get this error

enter image description here

Error C2446 '<': no conversion from 'unsigned __int64' to 'unsigned __int64 *' in c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector line 2326

Would anybody know what this could be referring to, and possibly how to fix it?


As requested, here the full error log:

1>------ Rebuild All started: Project: Test_CreatePythonBindings, Configuration: Debug x64 ------
1>example.cpp
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): error C2446: '<': no conversion from 'unsigned __int64' to 'unsigned __int64 *'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2325): note: while compiling class template member function 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>> &std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>::operator +=(__int64)'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2545): note: see reference to function template instantiation 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>> &std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>::operator +=(__int64)' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2490): note: see reference to class template instantiation 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(3094): note: see reference to class template instantiation 'std::_Vb_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(3093): note: while compiling class template member function 'void std::vector<bool,std::allocator<_Ty>>::push_back(const bool &)'
1>        with
1>        [
1>            _Ty=bool
1>        ]
1>c:\pybind11-2.2.3\include\pybind11\pybind11.h(513): note: see reference to function template instantiation 'void std::vector<bool,std::allocator<_Ty>>::push_back(const bool &)' being compiled
1>        with
1>        [
1>            _Ty=bool
1>        ]
1>c:\pybind11-2.2.3\include\pybind11\cast.h(1806): note: see reference to class template instantiation 'std::vector<bool,std::allocator<_Ty>>' being compiled
1>        with
1>        [
1>            _Ty=bool
1>        ]
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
1>Done building project "Test_CreatePythonBindings.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Phil-ZXX
  • 2,359
  • 2
  • 28
  • 40
  • 1
    Switch to the "Build" view in lower pane and paste the text here. There will be more information there. This error originated from vector implementation but it's not the place where it happened. – BJovke Jun 12 '18 at 09:18
  • Also, try and produce a [mcve] (note the "Complete" there). – Martin Bonner supports Monica Jun 12 '18 at 09:21
  • @BJovke Added the full output, hope it helps. – Phil-ZXX Jun 12 '18 at 09:29
  • Yes, this helps, the error is in "cast.h". I have to take a look at it. – BJovke Jun 12 '18 at 09:37
  • Actually the error is in "pybind11.h", but the lines in the error log you posted do not match the lines from ZIP file you referenced in your question. So the code is probably not the same. Can you redownload the ZIP file, build with it again and post the errors again? – BJovke Jun 12 '18 at 09:44
  • Re-downloaded and updated include screenshot + error log – Phil-ZXX Jun 12 '18 at 09:49
  • `call.args_convert.push_back(false);` in pybind11.h gives this error. `call` is `struct function_call` and `args_convert` is `std::vector` so this should work. My guess is that some of the Python's header/source files or some other files you're including are redefining some of these things somehow. Can you search python directory and any other header files you've included for `function_call` and `args_convert`? – BJovke Jun 12 '18 at 10:53
  • I think I've found something. In cpython GitHub repository there's a `function_call` function in file `Objects/funcobject.c`. This might interfere with pybind11 but I'm not sure since I don't have Python installed. – BJovke Jun 12 '18 at 11:00
  • I've pasted the search output here: https://pastebin.com/raw/s5qckwVu – Phil-ZXX Jun 12 '18 at 11:22
  • As for *funcobject*, I only found c:\Program Files\Python36\include\funcobject.h which I pasted here https://pastebin.com/raw/yFz58HeG for reference. – Phil-ZXX Jun 12 '18 at 11:27

1 Answers1

0

It appears to be a VS 2017 issue related to

  std::vector<bool>

Separate question asked here: Pushback on vector<bool> fails - VS 2017

Phil-ZXX
  • 2,359
  • 2
  • 28
  • 40