Boost logo

Boost :

From: ab_goldin (agoldin_at_[hidden])
Date: 2002-03-01 17:52:40


In a library I am trying to wrap exists a class the whole purpose of
which is to enclose some global variables. Its fields are declared as
static. I have no idea how to wrap them in boost::python. An obvious
way fails:

//------------ test.cpp -----------------

class test {
public:
  static int a;
  int b;
};

#include <boost/python/class_builder.hpp>

namespace python = boost::python;

namespace {
  BOOST_PYTHON_MODULE_INIT(tst)
  {
    // create an object representing this extension module
    python::module_builder module("tst");
    python::class_builder<test> test_class(module, "test");
    test_class.def_readonly(&test::a, "a");
    test_class.def_readonly(&test::b, "b");
  }
}
//--------------------

Compilation:

cd /home/goldin/camwa/supermix-python/
make -k test
g++ -I/home/goldin/python/src/boost_1_27_0 -I/usr/include/python2.1
-Wall -I/home/goldin/python/src/boost_1_27_0 -c test.cpp
test.cpp: In function `void {anonymous}::init_module_tst()':
test.cpp:28: no matching function for call to
`boost::python::class_builder<test,boost::python::detail::held_instance<test>
>::def_readonly (int *, const char[2])'

Compiler does not complain about non-static field.

I am not using C++ that much, so I could miss something obvious. Could
some kind soul please give me a hint what to do?

I am running Debian testing (woody), i386

gcc:

gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 (Debian prerelease)

boost 1.27 freshly from boost website (not one packaged with debian).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk