PROBLEM: compiling C programs that link to Python

Nikola Milutinovic Nikola.Milutinovic at
Sun Jan 4 17:10:18 CET 2004

Hi all.

I'm not subscribed to the list, so all replies to me mail directly.

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 {
} 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.

The idea I'd like to float here is that you guys remove the trailing ";" from your "#define ...". The source looks much more natural with a semicolon at the end.

I know that this idea is going to create resistance, "it is working for us", "it is working on GCC", "it will create other changes in existing source base", "you've solved your problem". The only argument in my favour I can give is that, well, C standard doesn't recognize "; ;" in "structs". So, if you want to create CPP constructs like that "#define", create them so they can be used without breaking the standards.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list