]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore(c): fix build warnings on win32
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 22 Dec 2022 21:28:12 +0000 (21:28 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 22 Dec 2022 23:45:33 +0000 (23:45 +0000)
psycopg_c/psycopg_c/_psycopg.pyx
psycopg_c/psycopg_c/_psycopg/waiting.pyx
psycopg_c/psycopg_c/types/array.pyx

index 9d2b8baedfa483c90906f31f474714bad241c179..a4d28b3c4ffcd7bc5aa0b4c05268663f40359df4 100644 (file)
@@ -28,6 +28,11 @@ PG_BINARY = _py_Format.BINARY
 
 cdef extern from *:
     """
+/* Include this early to avoid a warning about redefined ARRAYSIZE in winnt.h */
+#ifdef MS_WINDOWS
+#include <winsock2.h>
+#endif
+
 #ifndef ARRAYSIZE
 #define ARRAYSIZE(a) ((sizeof(a) / sizeof(*(a))))
 #endif
index 0af6c57c1870feb34d77832e29bbe40294f13641..c778c36e9adf8b013adac2b868694215a6919095 100644 (file)
@@ -168,7 +168,7 @@ def wait_c(gen: PQGen[RV], int fileno, timeout = None) -> RV:
     if timeout is None:
         ctimeout = -1.0
     else:
-        ctimeout = float(timeout)
+        ctimeout = <float>float(timeout)
         if ctimeout < 0.0:
             ctimeout = -1.0
 
index 9abaef9ffefc7c66415da1ca7a7e86e66686fbd1..280d33c28170b0ee50ec3c8def3de68cca99952c 100644 (file)
@@ -164,7 +164,7 @@ cdef object _parse_token(
     if has_quotes:
         end -= 1
 
-    cdef int length = (end - start)
+    cdef Py_ssize_t length = (end - start)
     if length == 4 and not has_quotes \
             and start[0] == b'N' and start[1] == b'U' \
             and start[2] == b'L' and start[3] == b'L':