[Pyrex] External declarations and GCC-XML?

John J Lee jjl at pobox.com
Sat Jul 19 20:37:16 CEST 2003


Any plans to get rid of the need for Pyrex declarations for external
symbols?  The need for cut-n-pasting external declarations from header
files seems like the only major Pyrex wart when wrapping C code.  I
suppose it would still be desirable to explicitly "import" external
symbols from C headers, but at least you wouldn't have to cut-n-paste the
full types over.

I don't know what would be most time-consuming about implementing this,
but I guess it's mostly about the difference between Pyrex syntax and C
syntax?  If so, might something like GCC-XML be a good solution?

As you're probably aware, David Abrahams has used GCC-XML to make this
impressive-looking Boost.Python code generator:

http://www.boost.org/libs/python/pyste/


gcc is portable, and presumably GCC-XML doesn't break that too badly.  Of
course, the major pain with it is that it requires recompiling gcc (either
with a patch, or downloading the project's prepatched gcc 3.0.4).  Still,
adding this feature wouldn't prevent people using hand-written
declarations.  And gcc needn't be used to compile the Pyrex-generated C
code, of course -- it would only be there as the .h file parser.

I couldn't see any reference on the gcc list to merging GCC-XML into gcc
(but the mailing list search page makes it impossible to search for
'gcc-xml', so I had to use Google).  I did find this, seems to be a
separate effort:

http://gcc.gnu.org/ml/gcc/2003-01/msg00726.html


Would this feature make Pyrex code using this feature less portable?
Hmm, what happens if there are platform-dependent headers?  If Pyrex
understood C headers, some Pyrex code using this feature would have to be
compiled on the platform where it is destined to execute, but that
wouldn't be possible on machines where gcc & GCC-XML isn't available.
But since currently you have to hand-write declarations, you don't have
portable code in that case anyway (unless you can conditionally cimport
somehow). No doubt things could be set up so there was a choice between
using GCC-XML and hand-written .pxd files, so unusual platforms could be
supported.


BTW, having tracebacks into Pyrex code is great!


John





More information about the Pyrex mailing list