[C++-sig] Attributes of type char[x]...

Mattias Brändström mattias.brandstrom at todos.se
Wed Sep 17 09:58:14 CEST 2008


Hello!

I'm trying to expose a C++ (using Boost.Python) class containing public char[] members to python. I would have guessed that I would be able to do this using def_readwrite(). However, I get a compilation error when trying to do so. Here is a minimal example of what I'm trying to do:

#include <boost/python.hpp>

class A
{
public:
    char foo[10];
};

BOOST_PYTHON_MODULE(pyconfdb)
{
    using namespace boost::python;

    class_<A>("A")
        .def_readwrite("foo", &A::foo)
    ;
}

This is the compilation error message:
c:\3pty\boost_1_35_0\boost\python\data_members.hpp(64) : error C2440: '=' : cannot convert from 'const char [10]' to 'char [10]'

I have not used the Boost.Python library for that long so there might be something obvious I'm missing. Any tips will be greatly appreciated!

Regards,
Mattias



More information about the Cplusplus-sig mailing list