pymem.h In function '__declspec'

Jeff Epler jepler at unpythonic.net
Mon Mar 7 18:57:18 EST 2005


What does this command print?
    gcc -c -I/usr/Python-2.3.3/Include -x c -o /dev/null \
        /usr/Python-2.3.3/Include/pymem.h
If it prints an error like the one you included in this message, then
the set of header files in /usr/Python-2.3.3/Include is damaged,
incomplete, or wrong for your compiler environment.  If the files in
/usr/Python-2.3.3 are from SUSE, then contact your vendor.

If it doesn't give an error, but the build of your "application RPM"
does, then investigate the compiler defines that are present in the
application that aren't on the above commandline.  For instance, I was
able to get errors like yours by using inappropriate compiler
options:
    $ gcc -DPy_ENABLE_SHARED -DHAVE_DECLSPEC_DLL -c -x c -o /dev/null \
        /usr/include/python2.3/Python.h
    In file included from /usr/include/python2.3/Python.h:67:
    /usr/include/python2.3/pymem.h: In function `__declspec':
    /usr/include/python2.3/pymem.h:51: error: syntax error before "__declspec"
    ....

You're right that __declspec has something to do with Windows DLLs.
Normally, Python uses the macro 'PyAPI_FUNC' to declare all functions in
its header files.  For certain compilers (msvc, cygwin, mingw) it's
appropriate to use the __declspec extension to make the Python shared
library work properly.  For other compilers, PyAPI_FUNC doesn't do
anything special.  It's through the presence of absence of defines like
Py_ENABLE_SHARED and HAVE_DECLSPEC_DLL that Python decides how to define
PyAPI_FUNC, and this little detail is usually below the radar.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050307/93002d35/attachment.sig>


More information about the Python-list mailing list