[SciPy-dev] Creating a swig C++ wrapper with numpy.distutils

Matthieu Brucher matthieu.brucher at gmail.com
Tue Apr 8 10:34:45 EDT 2008


2008/4/7, Robert Kern <robert.kern at gmail.com>:
>
> On Mon, Apr 7, 2008 at 5:19 AM, Matthieu Brucher
> <matthieu.brucher at gmail.com> wrote:
> > hi,
> >
> > I'd like to create an extension with SWIG. By default, the extension is
> a C
> > one, but I need to create a C++ one with swig, that is adding the -c++
> flag
> > to the swig commandline. With setuptools, I just have to add the
> argument
> > options={'build_ext':{'swig_opts':'-c++'}} to the setup() command.
> >  Is there something like this in numpy.distutils ? If yes is it possible
> to
> > add the option only to one extension with the configuration tool ?
>
>
> Don't add swig_opts to the build_ext command; it affects every SWIG
> wrapper, which may not be what you want. Instead, add swig_opts='-c++'
> to the Extension() constructor (or add_extension() method call) of the
> extension that needs it.
>

I managed to use this, but then the wrapper'extension is .c and not .cpp.
I digged into the code and found out that the builder can infere the type of
the generated file with the first line, so I added :
//-*-c++-*-
without the additional options and everything went smoothly.

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20080408/3a56f255/attachment.html>


More information about the SciPy-Dev mailing list