[C++-sig] splitting a module definition over several cpp files

Alex Mohr amohr at pixar.com
Mon Sep 24 21:07:15 CEST 2007


Matthew Scouten wrote:
> The library I am trying to wrap is of unwieldy size.
> 
> I would like to split my boost python "declarations" in to several
> different cpp files.
> This does not work.
> 
> I know I saw a way to do this somewhere, but I cannot find it now.
> Somthing invloling a function called from the end of '//first code'
> that contained '//second code'.
> I think the 'scope()' function may have been involved.

Probably the simplest thing to do is to just call functions from a 
central module definition.  e.g.

//file 1
BOOST_PYTHON_MODULE(poc)
{
    wrapFoo();
    wrapBar();
    wrapBaz();
}

//file 2
void wrapFoo() {
    class_<...>(...);
}

//file 3
void wrapBar() {
    class_<...>(...);
}

//file 4
void wrapBaz() {
    class_<...>(...);
}

Alex



More information about the Cplusplus-sig mailing list