[C++-sig] Another BPLV2 newbie...

David Abrahams david.abrahams at rcn.com
Wed Jun 26 15:46:14 CEST 2002


----- Original Message -----
From: "Hugo van der Merwe" <s13361562 at bach.sun.ac.za>
To: <c++-sig at python.org>
Sent: Monday, June 24, 2002 5:26 PM
Subject: [C++-sig] Another BPLV2 newbie...


> I recently finally got round to taking a look at V2, and seeing if I can
> do something with it. (Seems I can't ;)
>
> I immediately ran into two things I don't know how to handle.
>
> First is related to trying to wrap a library which has
> constructors with many many parameters. With V1 the solution was:
>
> python ../gen_all.py 20
>
> 20 isn't quite necessary. How do I do something similar with V2?

We support up to 15 arguments by default on all compilers, 17 on non-EDG
compilers.

If you need support for more arguments, you can set #define
BOOST_PYTHON_MAX_ARITY to the number of arguments you need to support. You
can do this on the compiler command-line with -DBOOST_PYTHON_MAX_ARITY=20
or in your bjam invocation by adding

    <define>BOOST_PYTHON_MAX_ARITY=20

to your BUILD variable. For example,

    bjam "-sBUILD=debug <define>BOOST_PYTHON_MAX_ARITY=20" ...

However, if you are using an EDG-based compiler (see if the symbol
__EDG_VERSION is automatically #defined to find out), your compilations
will slow to a crawl, since their preprocessor is so slow -- we have
"manually" preprocessed many of the files which need expansion, too keep
compilation with EDG going at a reasonable pace, but only up to 15 args.
Changes are planned which will correct this problem so that fewer manually
preprocessed files will be needed, but they haven't been instituted yet. If
you need help manually preprocessing these files for more arguments, please
let me know and I'll make instructions available.

> Second, what is wrong with this:
>
> ==== test.cpp ====
> #define BOOST_PYTHON_V2
> #include <boost/python/module.hpp>
>
> class test
> {
> public:
>     test();
> };
>
> BOOST_PYTHON_MODULE_INIT(testmod)
> {
>     boost::python::module testmod("testmod");
>     testmod
> .add(
>     boost::python::class_<test>("test")
>     .def_init()
>     );
> }
> ==== test.cpp ====
>
> I get the following error tryinc to compile it:
>
> demeter.cpp:42: type
`boost::python::class_<Demeter::Settings,boost::python::detail::not_specifi
ed,boost::python::detail::not_specified,boost::python::detail::not_specifie
d>' is not yet defined

Looks like a missing #include <boost/python/class.hpp> to me.

> I'm worried I might have broken something by trying gen_all.py, but the
> tests appear to build fine. (I ran
> $ jam -sPYTHON_VERSION=2.2 -sPYTHON_ROOT=/usr
> in libs/python/test, with BOOST_ROOT set in environment.)

Don't use "jam"; the executable you want is "bjam" (the name matters).

HTH,
Dave







More information about the Cplusplus-sig mailing list