From: Daniele Varrazzo Date: Thu, 22 Dec 2022 21:28:12 +0000 (+0000) Subject: chore(c): fix build warnings on win32 X-Git-Tag: 3.1.8~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47594940fe5772ad78915d6936c4e80815b89909;p=thirdparty%2Fpsycopg.git chore(c): fix build warnings on win32 --- diff --git a/psycopg_c/psycopg_c/_psycopg.pyx b/psycopg_c/psycopg_c/_psycopg.pyx index 9d2b8baed..a4d28b3c4 100644 --- a/psycopg_c/psycopg_c/_psycopg.pyx +++ b/psycopg_c/psycopg_c/_psycopg.pyx @@ -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 +#endif + #ifndef ARRAYSIZE #define ARRAYSIZE(a) ((sizeof(a) / sizeof(*(a)))) #endif diff --git a/psycopg_c/psycopg_c/_psycopg/waiting.pyx b/psycopg_c/psycopg_c/_psycopg/waiting.pyx index 0af6c57c1..c778c36e9 100644 --- a/psycopg_c/psycopg_c/_psycopg/waiting.pyx +++ b/psycopg_c/psycopg_c/_psycopg/waiting.pyx @@ -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(timeout) if ctimeout < 0.0: ctimeout = -1.0 diff --git a/psycopg_c/psycopg_c/types/array.pyx b/psycopg_c/psycopg_c/types/array.pyx index 9abaef9ff..280d33c28 100644 --- a/psycopg_c/psycopg_c/types/array.pyx +++ b/psycopg_c/psycopg_c/types/array.pyx @@ -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':