[Cython] Syntax to declare a c++ class?

Stefan Behnel stefan_ml at behnel.de
Thu May 7 08:05:18 CEST 2009


Greg Ewing wrote:
> Robert Bradshaw wrote:
>> On May 6, 2009, at 1:33 PM, Dag Sverre Seljebotn wrote:
>>> cdef extern "C++" from "myheader.h":
>>>    cdef class A: ...
> 
> For Pyrex I'm thinking about using "cdef+" as a
> general prefix for C++-related declarations, e.g.
> 
>    cdef+ extern from "myheader.hpp":
>      ...
> 
>    cdef+ struct Foo:
>      ...

... and if we ever support the D language, we'd need a 'ddef' or 'cdefd'?

What about using some kind of qualifier as above, but more like

	cdef[c++] extern ...

or

	cdef(c++) extern ...

or even

	cdef("c++") extern ...

to come a bit closer to pure Python code.

That would be easily extensible to

	cdef[fortran] ...
	cdef[D]

and would simply default to

	cdef[C]

if no qualifier is provided in a plain "cdef".

Stefan



More information about the Cython-dev mailing list