[Pyrex] help with structs and arrays

Greg Ewing greg at cosc.canterbury.ac.nz
Fri Oct 1 06:14:37 CEST 2004


Tom Jenkins <tjenkins at devis.com>:

> MAXSTRING = 120
> MAXPARTCLASSES = 500
> 
> cdef extern from "genpsdpage.h":
> 	cdef struct genpsd_params:
> 		char psdkernel[MAXSTRING]

That won't work. You haven't declared MAXSTRING and MAXPARTCLASSES
as constants, but as variables with initial values, so you can't
use them as array sizes.

What you want to do is this:

  cdef extern from "genpsdpage.h":

    cdef enum:
      MAXSTRING = 120
      MAXPARTCLASSES = 500

    def struct genpsd_params:
      char psdkernel[MAXSTRING]

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list