[ python-Bugs-870855 ] C interface definition of PyObject_HEAD is problematic

SourceForge.net noreply at sourceforge.net
Mon Jan 5 06:44:33 EST 2004


Bugs item #870855, was opened at 2004-01-05 12:44
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=870855&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nikola Milutinovic (alokin1)
Assigned to: Nobody/Anonymous (nobody)
Summary: C interface definition of PyObject_HEAD is problematic

Initial Comment:
I ran into a small problem, for which we have found a
workaround. I was compiling PostgreSQL v7.4.1 and it's
PL/Python module. Compilation failed on lines which had
this:

typedef struct PLyPlanObject {
  PyObject_HEAD;
  ...
} PLyPlanObject;

The problem was in that semicolon following
"PyObject_HEAD", since that is a CPP define which
expands to this:

typedef struct PLyPlanObject {
  int ob_refcnt ; struct _typeobject * ob_type ; ;
  ...
} PLyPlanObject;

That extra ";" breaks compiling on strict ANSI-C
compilers (or at least on mine - DEC CC on Tru64 UNIX).
The workaround was to remove the ";" from plpython.c
source file. It could be that GNU C is not complaining
on this, since it is more lenient on C irregularities.

----------------------------------------------------------

Could you change the definition of "PyObject_HEAD" to
exclude that ";" at the end?

If you do that, we can all write in our C source that
identifier "PyObject_HEAD" with ";" at the end. That
looks a bit more C-like than without it.

Nix.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=870855&group_id=5470



More information about the Python-bugs-list mailing list