[Pyrex] Initialisation of cdef global arrays with constants [resend]

David M. Cooke cookedm at physics.mcmaster.ca
Fri Jan 7 23:47:28 CET 2005


On Sat, Jan 08, 2005 at 07:01:21AM +1100, sjmachin at lexicon.net wrote:
> Sorry if you are seeing this again, but I sent it on Dec 31 and didn't get my own copy 
> back. As 2 other messages arrived from the Pyrex list this morning,  I'm trying again.
> 
> ------- Forwarded message follows -------
> Hello all,
> 
> Where in Python I would have at global level:
> 
> blah_table = (0, 1, 2, 42, 255)
> 
> or in C:
> 
> static const int blah_table[5] = {0, 1, 2, 42, 255};
> 
> Pyrex appears not to support (yet?) a statement like:
> 
> cdef int blah_table[5] = {0, 1, 2, 42, 255}

You coult put your C version in a header file, and add (untested :-)

cdef exterm from "constants.h":
    cdef extern int blah_table[5]

to your Pyrex file.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca



More information about the Pyrex mailing list