Boost logo

Boost Users :

From: Mazay (mazay0_at_[hidden])
Date: 2007-12-29 13:22:50


Hello, all.

I have encountered compile errors on attempt to add Python support to
an existing boost installation.

Configuration:
  boost 1.33.1
  Intel C++ Compiler 8.1.018 for Windows
  Python 2.5

// --------Build script (icc_python.bat): -------------

SET INTEL_BASE_MSVC_TOOLSET=vc-7_1
SET TOOLS=intel-win32
SET INTEL_PATH=c:\Install\Intel\CPP\Compiler80\Ia32
SET INTEL_VERSION=81
SET PYTHON_VERSION= 2.5
SET PYTHON_ROOT=C:\Install\Python25
bjam --prefix=C:\prg\boost --with-python install 1>icc_python.log
2>icc_python.err

//----- end of build script ---------

The following errors occur:

C:\prg\boost_1_33_1\boost/python/converter/pyobject_traits.hpp(33): error:
expression must have a constant value
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type);
^
detected during instantiation of class
"boost::python::converter::pyobject_traits<PyTypeObject>" at line 33

C:\prg\boost_1_33_1\boost/python/converter/pyobject_traits.hpp(34): error:
expression must have a constant value
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List);
^
detected during instantiation of class
"boost::python::converter::pyobject_traits<PyListObject>" at line 34

C:\prg\boost_1_33_1\boost/python/converter/pyobject_traits.hpp(35): error:
expression must have a constant value
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int);
^
detected during instantiation of class
"boost::python::converter::pyobject_traits<PyIntObject>" at line 35

..................... and so on ..........

I've made some investigation of the issue.
The error occur in file pyobject_traits.hpp in this code:

# define BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(T) \
template <> struct pyobject_traits<Py##T##Object> \
: pyobject_type<Py##T##Object, &Py##T##_Type> {}

// This is not an exhaustive list; should be expanded.
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Type); //line 33
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(List); //line 34
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Int); //line 35
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Long);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Dict);
BOOST_PYTHON_BUILTIN_OBJECT_TRAITS(Tuple);

Variables PyType_Type, PyList_Type, PyInt_Type and etc has type
PyTypeObject and defined in Python include files in the following way:

PyAPI_DATA(PyTypeObject) PyList_Type;

PyAPI_DATA is a macro. In this case it unrolls in the code:

extern __declspec(dllimport) PyTypeObject PyList_Type;

So we have the following code after preprocessing:

extern __declspec(dllimport) PyTypeObject PyList_Type;
template <> struct pyobject_traits<PyListObject>
: pyobject_type<PyListObject, &PyList_Type> {};

and it causes error: expression must have a constant value

I tried to explicitly change PyList_Type declaration to:

extern __declspec(dllimport) const PyTypeObject PyList_Type;

but it didn't change anything.

Google didn't tell me anything useful so this list is my last resort.
Please, help.

Best regards, Ded Mazay.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net