….4 (numpy#30128)
The `import_array` macro, which is defined in the file
`numpy/core/code_generators/generate_numpy_api.py`, is intended for use
inside an internal SWIG function that is called in the generated C wrapper
file. This macro contains a return statement whose argument must match the
function definition.
Until version 4.3 of SWIG, the aforementioned function returned a `void*` value.
However, in version 4.4, the return value was changed to `int`. This causes compilation of code using import_array() to fail with the following error message: `returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion].`
This commit resolves the issue by returning either `NULL` or `0`, depending
on the SWIG version being used (< 3.4 or >= 3.4, respectively). This change
has been successfully tested against SWIG versions 4.3 and 4.4.
Closes: numpy#30122
Backport of #30128.
The import_array macro, which is defined in the file numpy/core/code_generators/generate_numpy_api.py, is intended for use inside an internal SWIG function that is called in the generated C wrapper file. This macro contains a return statement whose argument must match the function definition.
Until version 4.3 of SWIG, the aforementioned function returned a void* value. However, in version 4.4, the return value was changed to int. This causes compilation of code using import_array() to fail with the following error message: returning 'void *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion].
This commit resolves the issue by returning either NULL or 0, depending on the SWIG version being used (< 3.4 or >= 3.4, respectively). This change has been successfully tested against SWIG versions 4.3 and 4.4.
Closes: #30122