New submission from ov2k <ov2k.git...@gmail.com>:
PY_SSIZE_T_MAX is currently defined in Include/pyport.h as: #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) This is not an integer constant expression, which means it can't be used in preprocessor conditionals. For example: #if PY_SSIZE_T_MAX > UINT32_MAX will fail to compile. This was touched upon and ignored a long time ago: https://mail.python.org/archives/list/python-...@python.org/thread/27X7LINL4UO7DAJE6J3IFQEZGUKAO4VL/ I think the best fix is to move the definition of PY_SSIZE_T_MAX (and PY_SSIZE_T_MIN) next to the definition of Py_ssize_t, and use the proper corresponding limit macro. If Py_ssize_t is a typedef for ssize_t, then PY_SSIZE_T_MAX should be SSIZE_MAX. If Py_ssize_t is a typedef for Py_intptr_t, then PY_SSIZE_T_MAX should be INTPTR_MAX. There's a minor complication because Py_ssize_t can be defined in PC/pyconfig.h. I'm not so familiar with the various Windows compilers, so I'm not sure what's best to do here. I think __int64 has a corresponding _I64_MAX macro, and int obviously has INT_MAX. ---------- components: C API messages: 412670 nosy: ov2k priority: normal severity: normal status: open title: PY_SSIZE_T_MAX is not an integer constant expression type: compile error versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46664> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com