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 {
  static int a;
  int b;

#include <boost/python/class_builder.hpp>

namespace python = boost::python;

namespace {
    // 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");


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
>::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 -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, gregod at, cpdaniel at, john at