cython + scons + c++

Dave Angel d at davea.name
Thu Mar 8 10:44:58 EST 2012


On 03/08/2012 09:23 AM, Neal Becker wrote:
> Is there a version of cython.py, pyext.py that will work with c++?
>
> I asked this question some time ago, but never got an answer.
>
> I tried the following code, but it doesn't work correctly.  If the commented
> lines are uncommented, the gcc command is totally mangled.
>
> Although it did build my 1 test extension OK, I didn't use any libstdc++ - I
> suspect it won't link correctly in general because it doesn't seem to treat the
> code as c++ (treats it as c code).
>
> cyenv = Environment(PYEXT_USE_DISTUTILS=True)
> cyenv.Tool("pyext")
> cyenv.Tool("cython")
> import numpy
>
> cyenv.Append(PYEXTINCPATH=[numpy.get_include()])
> cyenv.Replace(CYTHONFLAGS=['--cplus'])
> #cyenv.Replace(CXXFILESUFFIX='.cpp')
> #cyenv.Replace(CYTHONCFILESUFFIX='.cpp')
>
>

I don't know anything about writing c/c++ code with Python.  I have 
plenty of experience with each, but not together.

But the usual C++ answer is to use an extern "C"  declaration for any 
function you need to be visible to the outside world.  It prevents the 
usual C++ name mangling.

(It therefore also prevents function overloading and can't generally be 
used on class member functions)



-- 

DaveA




More information about the Python-list mailing list