[Pyrex] simple statement list error

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Mar 3 02:11:36 CET 2004


Christopher Fonnesbeck <chris at fonnesbeck.org>:

> to this:
> 
> #ifndef GRASS_VECT_H
> #define GRASS_VECT_H
> #include "gis.h"
> #include "vect/digit.h"
> 
> /* --- ANSI prototypes for the lib/vector/Vlib functions --- */
> /* "Public" functions, for use in modules */
>      /* Basic structures */
>        /* Points (line) */
> struct line_pnts *Vect_new_line_struct()
> int Vect_append_point (struct line_pnts *, double, double, double)
> int Vect_append_points (struct line_pnts *, struct line_pnts *, int)

That's *not* Pyrex code, it's just lightly-edited C code.
There's a lot more to converting C declarations to Pyrex
than just removing all the semicolons. In particular:

* You can't use C preprocessor directives (#include, etc.)
  in Pyrex.

* Pyrex uses Python-style comments, not C-style ones.

* You will need Pyrex versions of the declarations of
  C data types (struct line_pnts, etc.) that you use.

A proper Pyrex version of the above interfaces would look
more like this:

cdef extern from "gis.h":
  # Insert Pyrex versions of needed declarations from gis.h here

cdef extern from "vect/digit.h":
  # Insert Pyrex versions of needed declarations from vect/digit.h
  # here

cdef extern from "whateveritis.h": 
  line_pnts *Vect_new_line_struct()
  int Vect_append_point(line_pnts *, double, double, double)
  int Vect_append_points(line_pnts *, struct line_pnts *, int)
 

I suggest you study Michael JasonSmith's "Quick Guide to Pyrex"
(linked from the Pyrex page). It contains a couple of worked
examples which will give you an idea of what's required to
turn a set of C declarations into Pyrex declarations. Then
you can go back to the Language Overview for more detailed
information.

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