PROBLEM: compiling C programs that link to Python

Discussion in 'Python' started by Nikola Milutinovic, Jan 4, 2004.

  1. 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.
     
    Nikola Milutinovic, Jan 4, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    891
    Kevin Spencer
    May 17, 2005
  2. lonelyplanet999

    Problem compiling java programs

    lonelyplanet999, Oct 16, 2003, in forum: Java
    Replies:
    6
    Views:
    518
    lonelyplanet999
    Oct 20, 2003
  3. Replies:
    12
    Views:
    1,672
    Dave Thompson
    Jan 10, 2005
  4. Coca
    Replies:
    7
    Views:
    754
    Aidan Grey
    Aug 24, 2004
  5. lone_eagle
    Replies:
    3
    Views:
    650
    psykeedelik
    May 26, 2009
Loading...

Share This Page