[Cython] Add includes to generated header files

Stefan Behnel stefan_ml at behnel.de
Fri Aug 3 05:43:33 CEST 2012


Jeff Copeland, 03.08.2012 02:18:
> I'm working on some C++ projects and I'm using cython to embed python
> code.  In an effort to make things easy for C++ devs not as familiar
> with cython/python I've made a small change to insert #includes in
> generated header files the same as is done in generated c code.  This
> allows one who is using code processed with cython to just include the
> header and not worry about any other headers that may be required to
> match data types.
> 
> Not having these headers is especially problematic because otherwise
> the error message presented at compilation can sometimes be quite
> cryptic.
> 
> Patch is attached.  Any reason this should not be done?

Hmm, didn't try your patch, but I guess it inserts includes for *all*
header files that the module that exports the C-API uses internally, right?

If so, I'm not sure that's always wanted. I see the advantage, sure, but it
may expose a lot of implementation details that external code may not
normally have to care about.

On the other hand, if extension types are exported, for example, it's
somewhat unlikely that their struct would compile without at least some of
those header files, because they almost always wrap some kind of externally
defined struct, pointer or whatever kind of other data type.

That sounds to me like we should make it a configurable option, something
like "capi_reexport_cincludes".

Stefan



More information about the cython-devel mailing list