DenisB
DenisB

Reputation: 165

Can't compile boost.python 1.65.1 with MSVC2015

I'm trying to generate Boost.Python 1.65.1 libraries with MSVC2015 and Python 3.7.

I'm having this compilation error:

libs\python\src\converter\builtin_converters.cpp(51): error C2440: 'return': cannot convert from 'const char *' to 'void *'
libs\python\src\converter\builtin_converters.cpp(51): note: Conversion loses qualifiers

The associated code (error is on the return) :

void* convert_to_cstring(PyObject* obj)
{
  return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
}

It looks like a real error to me. Is there an option in the b2 configuration to make the compiler more flexible on this ?

I used this as information:

https://codeyarns.com/2014/06/06/how-to-build-boost-using-visual-studio/

How to use Boost in Visual Studio 2010

Edit: I don't have this error with boost 1.69.0, but I have to use the 1.65.1

Edit2: They changed this code in 1.69.0:

PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(_PyUnicode_AsString(obj))) : 0;

Upvotes: 1

Views: 1573

Answers (1)

rustyx
rustyx

Reputation: 85351

It's a known issue, Boost.python didn't compile with Python 3.7. It's been fixed in Boost.python 1.67.

The fix is very simple and you can backport the patch to your local copy manually or just cast the result of _PyUnicode_AsString() to (void*) in libs/src/converter/builtin_converters.cpp(51).

Upvotes: 8

Related Questions