Hi, I tried to build swig-py with Python 3.9 on Windows, however get the following errors:
[[[ C:\usr\apps\python39\include\cpython\abstract.h(205,1): error C4204: nonstandard extension used: non-constant aggregate initializer [C:\usr\src\subversion\trunk-py39\build\win32\vcnet-vcproj\libsvn_swig_py.vcxproj] C:\usr\apps\python39\include\cpython\abstract.h(250,1): error C4204: nonstandard extension used: non-constant aggregate initializer [C:\usr\src\subversion\trunk-py39\build\win32\vcnet-vcproj\libsvn_swig_py.vcxproj] ]]] The error was raised from the line 205 in cpython/abstract.h in Python 3.9: [[[ 202 static inline PyObject * 203 PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg) 204 {
205 PyObject *args[2] = {self, arg};
206 ]]] The attached patch adds #pragma warning to make C4204 a warning instead of an error only on building swig-py with Visual Studio. -- Jun Omae <jun6...@gmail.com> (大前 潤)
Fix C4204 errors while building swig-py with Python 3.9 on Windows. * subversion/bindings/swig/include/svn_global.swg: Add #pragma to make C4204 a warning instead of an errors from Python.h in Python 3.9 with Visual Studio. * subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c: Ditto. Index: subversion/bindings/swig/include/svn_global.swg =================================================================== --- subversion/bindings/swig/include/svn_global.swg (revision 1883337) +++ subversion/bindings/swig/include/svn_global.swg (working copy) @@ -34,6 +34,11 @@ #ifdef SWIGPYTHON %begin %{ #define SWIG_PYTHON_STRICT_BYTE_CHAR +#if defined(_MSC_VER) +/* Prevent "non-constant aggregate initializer" errors from Python.h in + * Python 3.9 */ +# pragma warning(default : 4204) +#endif %} #endif Index: subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c =================================================================== --- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (revision 1883337) +++ subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (working copy) @@ -26,6 +26,12 @@ /* Avoid deprecation warnings about PY_SSIZE_T_CLEAN since Python 3.8 */ #define PY_SSIZE_T_CLEAN +#if defined(_MSC_VER) +/* Prevent "non-constant aggregate initializer" errors from Python.h in + * Python 3.9 */ +# pragma warning(default : 4204) +#endif + #include <Python.h>