Note that there are some explanatory texts on larger screens.

plurals
  1. POBuild Python (2.7) module on GCC 4.8 fails
    primarykey
    data
    text
    <p>I'm trying to build a Python Module/extension write using C API, but it fails:</p> <pre><code>% python2 cmath.py build running build running build_ext building 'c_math' extension creating build creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python2.7 -c c_math.c -o build/temp.linux-x86_64-2.7/c_math.o c_math.c:18:5: warning: initialization from incompatible pointer type [enabled by default] {"more", c_math_more, METH_VARARGS, "n + nn Using C API"}, ^ c_math.c:18:5: warning: (near initialization for ‘c_mathMethods[0].ml_meth’) [enabled by default] In file included from /usr/include/python2.7/Python.h:58:0, from c_math.c:1: /usr/include/python2.7/pyport.h:802:39: error: expected ‘,’ or ‘;’ before ‘void’ # define PyMODINIT_FUNC void ^ c_math.c:22:1: note: in expansion of macro ‘PyMODINIT_FUNC’ PyMODINIT_FUNC ^ error: command 'gcc' failed with exit status 1 </code></pre> <p>I've tried to build manually without distutils but i get same error/warnings messages</p> <p>c_math.c:</p> <pre><code>#include &lt;Python.h&gt; static PyObject * c_math_more(PyObject *self, PyObject *n, PyObject *nn) { if ( PyInt_Check(n) &amp;&amp; PyInt_Check(nn) ) { float cn, cnn, result; cn = PyInt_AsLong(n); cnn = PyInt_AsLong(nn); result = cn + cnn; return PyInt_FromLong(result); } } static PyMethodDef c_mathMethods[] = { {"more", c_math_more, METH_VARARGS, "n + nn Using C API"}, {NULL, NULL, 0, NULL} } PyMODINIT_FUNC initc_math() { (void) Py_InitModule("c_math", c_mathMethods); } int main(int argc, char *argv[]) { Py_SetProgramName(argv[0]); Py_Initialize(); initc_math(); } </code></pre> <p>And cmath.py:</p> <pre><code>from distutils.core import setup, Extension c_math = Extension('c_math', sources = ['c_math.c']) setup(name = 'c_math', version = '1.0', description = "c_math setup", ext_modules = [c_math]) </code></pre> <p>What i'm doing incorrect ?</p> <p>ps: please, if exists other errors on c_math.c (i mean errors that isn't showed by gcc) DON'T talk me, I want to find the errors by myself ^^</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload