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

Roman Yakovenko roman.yakovenko at gmail.com
Wed Sep 17 10:19:25 CEST 2008


On Wed, Sep 17, 2008 at 10:58 AM, Mattias Brändström
<mattias.brandstrom at todos.se> wrote:
> 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];
> };

You have 3 approaches to expose such code:

* to create a wrapper like this
  http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplusplus/code_repository/array_1.py?revision=1097&view=markup
  and the usage code attached

* to use ctypes module and expose "foo" address

* to use Py++ and have both possibilities :-)

HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: usage.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080917/d62c67d1/attachment.txt>


More information about the Cplusplus-sig mailing list