BUG: Avoid compilation error of wrapper file generated with SWIG >= 4.4 (#30128) #30130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #30128.
The
import_arraymacro, which is defined in the filenumpy/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 toint. 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
NULLor0, 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