@@ -133,8 +133,9 @@ typedef int Py_ssize_clean_t;
133
133
134
134
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
135
135
* format to convert an argument with the width of a size_t or Py_ssize_t.
136
- * C99 introduced "z" for this purpose, but not all platforms support that;
137
- * e.g., MS compilers use "I" instead.
136
+ * C99 introduced "z" for this purpose, but old MSVCs had not supported it.
137
+ * Since MSVC supports "z" since (at least) 2015, we can just use "z"
138
+ * for new code.
138
139
*
139
140
* These "high level" Python format functions interpret "z" correctly on
140
141
* all platforms (Python interprets the format string itself, and does whatever
@@ -152,19 +153,11 @@ typedef int Py_ssize_clean_t;
152
153
* Py_ssize_t index;
153
154
* fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
154
155
*
155
- * That will expand to %ld, or %Id, or to something else correct for a
156
- * Py_ssize_t on the platform.
156
+ * That will expand to %zd or to something else correct for a Py_ssize_t on
157
+ * the platform.
157
158
*/
158
159
#ifndef PY_FORMAT_SIZE_T
159
- # if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__ )
160
- # define PY_FORMAT_SIZE_T ""
161
- # elif SIZEOF_SIZE_T == SIZEOF_LONG
162
- # define PY_FORMAT_SIZE_T "l"
163
- # elif defined(MS_WINDOWS )
164
- # define PY_FORMAT_SIZE_T "I"
165
- # else
166
- # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
167
- # endif
160
+ # define PY_FORMAT_SIZE_T "z"
168
161
#endif
169
162
170
163
/* Py_LOCAL can be used instead of static to get the fastest possible calling
0 commit comments