diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index acaadf3..34a84c9 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -1537,7 +1537,7 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2) } #if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION) - PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2); + extern int _PyUnicode_Equal(PyObject *str1, PyObject *str2); return _PyUnicode_Equal(str1, str2); #elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION) @@ -1564,7 +1564,7 @@ static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable) static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len) { #if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION) - PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len); + extern Py_hash_t _Py_HashBytes(const void *src, Py_ssize_t len); return _Py_HashBytes(ptr, len); #else diff --git a/tests/setup.py b/tests/setup.py index 2e10c15..a4e78eb 100755 --- a/tests/setup.py +++ b/tests/setup.py @@ -20,31 +20,43 @@ # Windows uses MSVC compiler MSVC = (os.name == "nt") -# C compiler flags for GCC and clang -COMMON_FLAGS = [ - # Treat warnings as error - '-Werror', - # Enable all warnings - '-Wall', '-Wextra', - # Extra warnings - '-Wconversion', - # /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef - # 'Py_hash_t' is a C11 feature - "-Wno-typedef-redefinition", -] -CFLAGS = COMMON_FLAGS + [ - # Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a - # mixture of designated and non-designated initializers - '-std=c99', -] -CPPFLAGS = list(COMMON_FLAGS) -# FIXME: _Py_CAST() emits C++ compilers on Python 3.12. -# See: https://github.com/python/cpython/issues/94731 -if 0: - CPPFLAGS.extend(( - '-Wold-style-cast', - '-Wzero-as-null-pointer-constant', - )) +if not MSVC: + # C compiler flags for GCC and clang + COMMON_FLAGS = [ + # Treat warnings as error + '-Werror', + # Enable all warnings + '-Wall', '-Wextra', + # Extra warnings + '-Wconversion', + # /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef + # 'Py_hash_t' is a C11 feature + "-Wno-typedef-redefinition", + ] + CFLAGS = COMMON_FLAGS + [ + # Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a + # mixture of designated and non-designated initializers + '-std=c99', + ] + CXXFLAGS = list(COMMON_FLAGS) + # FIXME: _Py_CAST() emits C++ compilers on Python 3.12. + # See: https://github.com/python/cpython/issues/94731 + if 0: + CXXFLAGS.extend(( + '-Wold-style-cast', + '-Wzero-as-null-pointer-constant', + )) +else: + COMMON_FLAGS = [ + # Display warnings level 1 to 4 + '/W4', + # Treat all compiler warnings as compiler errors + '/WX', + ] + CFLAGS = COMMON_FLAGS + [ + '/std:c99' + ] + CXXFLAGS = list(COMMON_FLAGS) def main(): @@ -68,9 +80,8 @@ def main(): cflags = ['-I' + SRC_DIR] cppflags = list(cflags) - if not MSVC: - cflags.extend(CFLAGS) - cppflags.extend(CPPFLAGS) + cflags.extend(CFLAGS) + cppflags.extend(CXXFLAGS) # C extension c_ext = Extension(