Discussion:
[Cython] build failure on windows with 0.21b2 windows py27 x64
Stefan Behnel
2014-09-01 10:14:58 UTC
Permalink
the Problem reported by Ian Bell on v0.21b1 seems still to be there. With
v0.21a1 from https://github.com/cython/cython/releases/tag/0.21a1
everything seems to be fine. So maybe it's related to the method call
optimisations, you've mentioned.
I've also tested with windows+py27+x64 and I get the same errors;
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42437) : error C2146: syntax error : missing ')' before
identifier 'ifdef'
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42439) : error C2059: syntax error : 'else'
configobj.c(42449) : error C2059: syntax error : '}'
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
Could you copy lines 42430-42463 (i.e. the error lines plus a bit of
preceding context) from the generated C file and send them to me? (Please
make sure it's clear which lines are the offending ones.)

Thanks,

Stefan
Dirk Rothe
2014-09-01 07:55:21 UTC
Permalink
Hello Stefan,

the Problem reported by Ian Bell on v0.21b1 seems still to be there. With
v0.21a1 from https://github.com/cython/cython/releases/tag/0.21a1
everything seems to be fine. So maybe it's related to the method call
optimisations, you've mentioned.

I've also tested with windows+py27+x64 and I get the same errors;

configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42437) : error C2146: syntax error : missing ')' before
identifier 'ifdef'
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42439) : error C2059: syntax error : 'else'
configobj.c(42449) : error C2059: syntax error : '}'
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2

I've cythonized the following Code:
http://bpaste.net/show/a10f8b244c2d

with a setup.py like:
---------------------

import sys
from setuptools import setup
from setuptools.extension import Extension

from Cython.Distutils import build_ext

extensions = [Extension("configobj", ["configobj.py"])]
setup_info = dict(ext_modules=extensions, cmdclass={'build_ext':
build_ext})
sys.argv.extend(["build_ext", "-i"])
setup(**setup_info)


--dirk
Dirk Rothe
2014-09-01 10:25:04 UTC
Permalink
Post by Stefan Behnel
the Problem reported by Ian Bell on v0.21b1 seems still to be there. With
v0.21a1 from https://github.com/cython/cython/releases/tag/0.21a1
everything seems to be fine. So maybe it's related to the method call
optimisations, you've mentioned.
I've also tested with windows+py27+x64 and I get the same errors;
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42437) : error C2146: syntax error : missing ')' before
identifier 'ifdef'
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42439) : error C2059: syntax error : 'else'
configobj.c(42449) : error C2059: syntax error : '}'
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
Could you copy lines 42430-42463 (i.e. the error lines plus a bit of
preceding context) from the generated C file and send them to me? (Please
make sure it's clear which lines are the offending ones.)
Here we go, I have annotated the start/end with line numbers:

#if CYTHON_COMPILING_IN_CPYTHON ## Line 42431
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,
PyObject *arg) {
if (likely(PyCFunction_Check(func)
#ifdef __Pyx_CyFunction_USED
|| PyObject_TypeCheck(func, __pyx_CyFunctionType)
#endif
) && likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
} else {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
Py_INCREF(arg);
PyTuple_SET_ITEM(args, 0, arg);
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,
PyObject *arg) {
PyObject* args = PyTuple_Pack(1, arg);
return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
}
#endif ## Line 42455

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
if (likely(PyCFunction_Check(func)
#ifdef __Pyx_CyFunction_USED
|| PyObject_TypeCheck(func, __pyx_CyFunctionType)
#endif
) && likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
return __Pyx_PyObject_CallMethO(func, NULL);
} else {
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
}
#endif ## Line 42469

--dirkse
Stefan Behnel
2014-09-05 18:47:47 UTC
Permalink
Post by Dirk Rothe
I've also tested with windows+py27+x64 and I get the same errors;
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42437) : error C2146: syntax error : missing ')' before
identifier 'ifdef'
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42439) : error C2059: syntax error : 'else'
configobj.c(42449) : error C2059: syntax error : '}'
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
#if CYTHON_COMPILING_IN_CPYTHON ## Line 42431
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,
PyObject *arg) {
if (likely(PyCFunction_Check(func)
#ifdef __Pyx_CyFunction_USED
|| PyObject_TypeCheck(func, __pyx_CyFunctionType)
#endif
) && likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
} else {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
[...]
Thanks. My guess is that the macro nesting is a bit too heavy for MSVC
here. I pushed a change to the master branch that simplifies it. Could you
give it another try?

https://github.com/cython/cython/commit/2a1f74aac867fee81e2ddf073f16519f3f454bac

Stefan
Dirk Rothe
2014-09-06 08:02:53 UTC
Permalink
Post by Stefan Behnel
Post by Dirk Rothe
I've also tested with windows+py27+x64 and I get the same errors;
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42437) : error C2146: syntax error : missing ')' before
identifier 'ifdef'
configobj.c(42437) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42439) : error C2059: syntax error : 'else'
configobj.c(42449) : error C2059: syntax error : '}'
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
configobj.c(42463) : error C2121: '#' : invalid character : possibly the
result of a macro expansion
error: command '"C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2
#if CYTHON_COMPILING_IN_CPYTHON ## Line 42431
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,
PyObject *arg) {
if (likely(PyCFunction_Check(func)
#ifdef __Pyx_CyFunction_USED
|| PyObject_TypeCheck(func, __pyx_CyFunctionType)
#endif
) && likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
} else {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
[...]
Thanks. My guess is that the macro nesting is a bit too heavy for MSVC
here. I pushed a change to the master branch that simplifies it. Could you
give it another try?
https://github.com/cython/cython/commit/2a1f74aac867fee81e2ddf073f16519f3f454bac
Thanks Stefan! The latest Trunk works fine for me now.

--dirk

Loading...