Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2 Python bindings fail to compile with gcc-4.3

open
nobody
None
5
2009-02-11
2009-02-11
Mathieu Blondel
No

On two of my machines (Debian Sid and Ubuntu Intrepid), Python bindings fail to compile with gcc-4.3. This is the message I get:

$ python setup.py build
running build
running build_py
running build_ext
building '_zinnia' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c zinnia_wrap.cxx -o build/temp.linux-i686-2.5/zinnia_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
zinnia_wrap.cxx: In constructor ‘swig::PyObject_ptr::PyObject_ptr(PyObject*, bool)’:
zinnia_wrap.cxx:2536: warning: suggest explicit braces to avoid ambiguous ‘else’
zinnia_wrap.cxx: In function ‘char* zinnia_Character_toString(zinnia::Character*)’:
zinnia_wrap.cxx:2939: error: ‘strcpy’ is not a member of ‘std’
error: command 'gcc' failed with exit status 1

However, everything compiles fine with:
$ CC=gcc-4.1 python setup.py build

Discussion

  • LI Daobing
    LI Daobing
    2009-02-12

    patch as follows, (and you need regenerate the python bindings with swig)

    $ diff -ura zinnia-0.02.orig zinnia-0.02
    diff -ura zinnia-0.02.orig/swig/zinnia.i zinnia-0.02/swig/zinnia.i
    --- zinnia-0.02.orig/swig/zinnia.i 2008-09-14 00:59:37.000000000 +0800
    +++ zinnia-0.02/swig/zinnia.i 2009-02-12 21:07:34.000000000 +0800
    @@ -27,7 +27,7 @@
    if (!self->toString(buf, sizeof(buf)))
    return 0;
    char *r = new char[strlen(buf) + 1];
    - std::strcpy(r, buf);
    + strcpy(r, buf);
    return r;
    }
    }