Title: conflicting definition of ssize_t in pyconfig.h
Type: compile error Stage: resolved
Components: Windows Versions: Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: JoeyGrajciar, amaury.forgeotdarc, loewis, mhammond, pablogsal, steve.dower, tim.golden, wrohdewald, zach.ware
Priority: normal Keywords: patch

Created on 2011-03-30 00:11 by wrohdewald, last changed 2021-03-01 11:19 by pablogsal. This issue is now closed.

File name Uploaded Description Edit
no-ssize_t.patch amaury.forgeotdarc, 2011-03-30 07:44 review
Pull Requests
URL Status Linked Edit
PR 24479 merged JoeyGrajciar, 2021-02-08 07:34
Messages (9)
msg132558 - (view) Author: Wolfgang Rohdewald (wrohdewald) Date: 2011-03-30 00:11
compiling pykde on windows with msvc2010 on a 32bit Windows 7:

R:\include\msvc\sys/types.h(52) : error C2371: 'ssize_t' : redefinition; different basic types
        c:\python27\include\pyconfig.h(201) : see declaration of 'ssize_t'

I can fix this by defining ssize_t as long in pyconfig.h or 
as int in kdewin/include/msvc/sys/types.h

the original files from windows define SSIZE_T as long so to
me this seems like a bug in pyconfig.h, it should say
typedef _W64 long ssize_t

Python27\include\pyconfig.h says (same in Python32):

#ifdef MS_WIN64
typedef __int64 ssize_t;
typedef _W64 int ssize_t;

while kdewin/include/msvc/sys/types.h says:

typedef SSIZE_T ssize_t;

SSIZE_T is defined in Microsoft SDKs/Windows/v7.0A/Include/BaseTsd.h:


and LONG_PTR from same directory, intsafe.h:
#if (__midl > 501)
typedef [public]          __int3264 LONG_PTR;
#ifdef _WIN64
typedef __int64             LONG_PTR;
typedef _W64 long           LONG_PTR;
#endif // WIN64
#endif // (__midl > 501)

for __midl see
msg132569 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-03-30 05:41
Where does R:\include\msvc\sys/types.h come from?
msg132571 - (view) Author: Wolfgang Rohdewald (wrohdewald) Date: 2011-03-30 06:50
types.h is from kdewin/include/msvc/sys

git clone git://

types.h uses SSIZE_T but that is nowhere defined in KDE, so it must be the original one from msvc
msg132574 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-03-30 07:44
Should Python.h systematically avoid defining symbols without a Py prefix?
See attached patch, which defines Py_ssize_t in pyconfig.h.

The same can be said for other symbols defined there: pid_t, copysign, hypot.
msg132788 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2011-04-02 06:52
As Tim Roberts says on the python-win32 list:

> Actually, on closer examination, it may be a bit difficult to sell this.  The Microsoft compilers do not define this symbol at all.  The SDK defines SSIZE_T (as a long).  Nothing defines ssize_t. for the full post.

So yeah, the conclusion is that we shouldn't define such symbols incase someone else does too.  So conceptually I'm +1 on that patch (I'm yet to try it and probably will not get a chance for a week or 2)
msg220652 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-15 17:11
Is the patch acceptable?
msg236093 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-02-16 06:54
Can we have a formal patch review please?
msg236207 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-02-19 02:09
Patch needs updating, and I'd expect pyport.h to start by checking if HAVE_PY_SSIZE_T is defined. Otherwise, we may try to re-typedef Py_ssize_t.
msg387854 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-03-01 11:18
New changeset c994ffe69553cbb34f1cea6a4494d6e7657f41b0 by Jozef Grajciar in branch 'master':
bpo-11717: fix ssize_t redefinition error when targeting 32bit Windows app (GH-24479)
Date User Action Args
2021-03-01 11:19:01pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-03-01 11:18:43pablogsalsetnosy: + pablogsal
messages: + msg387854
2021-02-08 07:34:41JoeyGrajciarsetnosy: + JoeyGrajciar

pull_requests: + pull_request23271
stage: patch review
2019-03-15 22:51:20BreamoreBoysetnosy: - BreamoreBoy
2015-02-19 02:09:56steve.dowersetmessages: + msg236207
2015-02-16 06:54:16BreamoreBoysetmessages: + msg236093
2014-06-15 17:11:27BreamoreBoysetnosy: + BreamoreBoy, tim.golden, zach.ware, steve.dower

messages: + msg220652
versions: + Python 3.4, Python 3.5
2011-04-02 06:52:30mhammondsetmessages: + msg132788
2011-03-30 12:48:34wrohdewaldsetnosy: + mhammond
2011-03-30 07:44:16amaury.forgeotdarcsetfiles: + no-ssize_t.patch

nosy: + amaury.forgeotdarc
messages: + msg132574

keywords: + patch
2011-03-30 06:50:39wrohdewaldsetmessages: + msg132571
2011-03-30 05:41:12loewissetnosy: + loewis
messages: + msg132569
2011-03-30 00:11:04wrohdewaldcreate