PROBLEM: compiling C programs that link to Python

  • Thread starter Nikola Milutinovic
  • Start date
N

Nikola Milutinovic

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

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.

TYIA,
Nix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top