"initializer element is not constant"

Scott David Daniels scott.daniels at acm.org
Tue May 30 18:15:45 EDT 2006


emin.martinian at gmail.com wrote:
> When trying to compile python extensions written in C using "python
> setup.py build" on cygwin I get the following error:
> 
> foo.c: initializer element is not constant
> foo.c: error: (near initialization for `FooType.ob_type')
> 
> I remember someone telling me a long time ago that this had something
> to do with declspec and how dlls are imported on cygwin/python.  Can
> someone give me a pointer to how to build python extensions on cygwin?

Essentially, Python and its extensions must be compatibly compiled.
The distributed Windows python is compatible with MS C/C++ and (as a
result) also compatible with the Intel C/C++ compilers.  In addition,
"MinGW" (Minimal GNU for Windows) can compile C source to be compatible
with and use the MS C runtimes.  If you really want cygwin, you need to
compile the whole of Python with cygmin (I've no idea if that compile
cleanly).  If you want to use the MinGW approach, your call to setup is
something like "python setup.py -compiler=mingw32 -build " (look it up,
there are more details to know about.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list