[C++-sig] [Py++] Missing struct (was: [Py++] Generate Python code for ctypes?)

Roman Yakovenko roman.yakovenko at gmail.com
Sun Dec 13 21:54:07 CET 2009


On Sun, Dec 13, 2009 at 8:36 PM, Nikolaus Rath <Nikolaus at rath.org> wrote:
> Roman Yakovenko <roman.yakovenko at gmail.com> writes:
>>>> You can take a look on gmplib example:
>>>> http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/examples/gmplib_dev/
>>>> It is fully working.
>
> There seems to be a problem with the generated code:
>
> ,----
> | $ python
> | Python 2.6.4 (r264:75706, Nov  2 2009, 14:38:03)
> | [GCC 4.4.1] on linux2
> | Type "help", "copyright", "credits" or "license" for more information.
> | >>> import generated
> | Traceback (most recent call last):
> |   File "<stdin>", line 1, in <module>
> |   File "generated.py", line 227, in <module>
> |     ("init", ctypes.POINTER( ctypes.CFUNCTYPE( None, ctypes.c_void_p, ctypes.POINTER( fuse_conn_info ) ) )),
> | NameError: name 'fuse_conn_info' is not defined
> `----
>
> But struct fuse_conn_info is defined in fuse_common.h, which is included
> in fuse_lowlevel.h, which is included in myheader.h, which has been used
> to generate the code:
>
> ,----
> | $ cat project_env.py
> | import os
> | import sys
> |
> | lib = '/usr/lib/libfuse.so'
> |
> | class gmp:
> |     header_file = './myheader.h'
> |     symbols_file = lib
> |     shared_library_file = lib
> |     generated_code_dir = 'generated'
> `----
>
> ,----
> | $ cat myheader.h
> | #define __builtin_va_arg_pack_len int
> | #define _FILE_OFFSET_BITS 64
> | #define FUSE_USE_VERSION 26
> | #include <fuse/fuse_lowlevel.h>
> `----
>
> (the first define was necessary to prevent some gccxml errors).
>
> Why is the fuse_file_info struct not translated into ctypes code?

This is because Py++ tries to make some intelligent guess what to
export. By default it exports all declarations found in the files in
the same directory.

I suggest you to use include/exclude functionality to  create the
desired declarations set.


HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/


More information about the Cplusplus-sig mailing list