How to declare python ints in C extensions?
Tony Houghton
h at realh.co.uk
Sun Jan 4 18:47:29 EST 2009
On Sun, 04 Jan 2009 21:05:14 +0100
Christian Heimes <lists at cheimes.de> wrote:
> Philip Semanchuk schrieb:
> > This works for me:
> > PyModule_AddIntConstant(module, "O_CREAT", O_CREAT);
> >
> > I've had to learn a lot about writing extensions from looking at the
> > Python source code. Lots of valuable tricks to be learned there.
Thanks, that's perfect. I see it is documented, but I didn't know where
to look.
> This trick makes it even easier:
>
> #ifndef PyModule_AddIntMacro
> #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
> #endif
Good idea, but I'm a lot more experienced with C in general than in
interfacing it with python, so I already thought of it :-).
--
TH * http://www.realh.co.uk
More information about the Python-list
mailing list