[C++-sig] Adding custom C API functionality to boost.python modules

Stefan Seefeld seefeld at sympatico.ca
Mon Feb 11 16:27:30 CET 2008

Marcus Jannes wrote:
> Well, i can declare/define the function, but how does the boost.python module know of it? 
> Speaking of the part where you call Py_InitModule3(...) in the C API

I'm not sure what you are trying to achieve, and how this relates to 
boost.python (other than the question whether you can mix the 
boost.python with the Python C API).

With boost.python you call


While with Python's C API you would define

extern "C" void inityour_module_name()

You should use one of the two, not both. (Actually, I don't see any 
reason to use the C API to expose the extension module; there are good 
reasons to use boost.python instead.
However, the bodies of the two blocks above may contain any mix of the 
two APIs as you want.



       ...ich hab' noch einen Koffer in Berlin...

More information about the Cplusplus-sig mailing list