Re: M2Crypto build error - _lib.h:5: error: redefinition of typedef 'Py_ssize_t'

Pavel Shramov <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
On Fri, Oct 12, 2007 at 03:18:51PM +0100, Philip Kershaw wrote:
> Hello,
> 
> I'm getting a strange error installing M2Crypto on Redhat:
> 
> In file included from SWIG/_m2crypto_wrap.c:2528:
> /tmp/easy_install-F8-kVi/m2crypto-0.18.1/SWIG/_lib.h:5: error: redefinition of 
> typedef 'Py_ssize_t'
> 
> Has anyone seen anything similar?

I have same error on debian/unstable with 

$ gcc --version
gcc (GCC) 4.1.3 20070518 (prerelease) (Debian 4.1.2-8)

$ swig -version

SWIG Version 1.3.31

$ python
Python 2.4.4 (#2, Apr 26 2007, 00:02:45) 
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2

(Python 2.5.1 (r251:54863, Aug 17 2007, 00:51:07) is also installed)

As I remember this error appears when I'd upgraded python (or SWIG? 
don't remember, it was somewhat in the middle of summer). 
I commented out block with Py_ssize_t definition in local version.
Patch is attached. Maybe better solution will be something like

#if !defined(Py_ssize_t)
typedef....
#endif

		Pavel
fix-py_ssize_t.patch (text/plain, 510 B)
commit 96ba76af3dc40c071ff6fef7109c381ba19babe4
Author: Pavel Shramov <[email protected]>
Date:   Fri Oct 12 20:52:45 2007 +0400

    fixe compile error with some versions of SWIG (?)

diff --git a/SWIG/_lib.h b/SWIG/_lib.h
index c0760d4..c131e4a 100644
--- a/SWIG/_lib.h
+++ b/SWIG/_lib.h
@@ -1,9 +1,11 @@
 /* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */
 /* $Id$ */
 
+/*
 #if PY_VERSION_HEX < 0x02050000
 typedef int Py_ssize_t;
 #endif
+*/
 
 typedef struct _blob {
 	unsigned char *data;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.