summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2019-01-01 16:56:48 +0100
committerMichael Buesch <m@bues.ch>2019-01-07 20:26:19 +0100
commit9d5f41e4bb5f99c6e192b68ebfbb1fdf11f70013 (patch)
tree76357cfde1a9843ac5fd229f84e5cb1e1bf8c91c
parentcac84684592c45dd784df8021ec7e2426d3954f3 (diff)
downloadcython-9d5f41e4bb5f99c6e192b68ebfbb1fdf11f70013.tar.gz
Avoid const-ness compiler warning in __Pyx_PyObject_AsWritableString
This avoids the compiler warning warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] by casting the pointer to uintptr_t before removing the const-ness. The warning was introduced in 6cd70f0914d327f21feb8535810414c12e021737 Also merge the two places that define stdint types.
-rw-r--r--Cython/Utility/ModuleSetupCode.c26
-rw-r--r--Cython/Utility/TypeConversion.c18
2 files changed, 24 insertions, 20 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index 7642bcc2b..e7ef3c5b5 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -259,15 +259,31 @@
#ifdef _MSC_VER
#ifndef _MSC_STDINT_H_
#if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
#else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+ #endif
+ #endif
+ #if _MSC_VER < 1300
+ #ifdef _WIN64
+ typedef unsigned long long __pyx_uintptr_t;
+ #else
+ typedef unsigned int __pyx_uintptr_t;
+ #endif
+ #else
+ #ifdef _WIN64
+ typedef unsigned __int64 __pyx_uintptr_t;
+ #else
+ typedef unsigned __int32 __pyx_uintptr_t;
#endif
#endif
#else
- #include <stdint.h>
+ #include <stdint.h>
+ typedef uintptr_t __pyx_uintptr_t;
#endif
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c
index dac765fa6..724c8389e 100644
--- a/Cython/Utility/TypeConversion.c
+++ b/Cython/Utility/TypeConversion.c
@@ -68,9 +68,9 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
@@ -708,18 +708,6 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid
//@requires: StringTools.c::BuildPyUnicode
//@requires: CIntToDigits
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned short uint16_t;
- #else
- typedef unsigned __int16 uint16_t;
- #endif
- #endif
-#else
- #include <stdint.h>
-#endif
-
// NOTE: inlining because most arguments are constant, which collapses lots of code below
static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t width, char padding_char, char format_char) {