Skip to content

Initialize PyTypeObjects with PyVarObject_HEAD_INIT

This fixes the following errors on clang (Apple clang version 15.0.0 (clang-1500.3.9.4)):

src/infinity.c:271:2: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
        PyObject_HEAD_INIT(NULL)
        ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/object.h:142:9: note: expanded from macro 'PyObject_HEAD_INIT'
        (type)                   \
        ^~~~~~

and the following warnings on gcc (gcc (Debian 12.2.0-14) 12.2.0):

src/infinity.c:270:39: warning: missing braces around initializer [-Wmissing-braces]
  270 | PyTypeObject segments_Infinity_Type = {
      |                                       ^
In file included from /usr/local/include/python3.12/Python.h:44,
                 from src/infinity.c:29:
/usr/local/include/python3.12/object.h:142:9: warning: initialization of ‘long int’ from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  142 |         (type)                   \
      |         ^
src/infinity.c:271:9: note: in expansion of macro ‘PyObject_HEAD_INIT’
  271 |         PyObject_HEAD_INIT(NULL)
      |         ^~~~~~~~~~~~~~~~~~
/usr/local/include/python3.12/object.h:142:9: note: (near initialization for ‘segments_Infinity_Type.ob_base.ob_size’)
  142 |         (type)                   \
      |         ^
src/infinity.c:271:9: note: in expansion of macro ‘PyObject_HEAD_INIT’
  271 |         PyObject_HEAD_INIT(NULL)
      |         ^~~~~~~~~~~~~~~~~~

Fixes #20 (closed).

Edited by Leo P. Singer

Merge request reports

Loading