FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: Avoid compilation error of wrapper file generated with SWIG >= 4.4 (#30128) by charris · Pull Request #30130 · numpy/numpy · GitHub

/ numpy Public

BUG: Avoid compilation error of wrapper file generated with SWIG >= 4.4 (#30128) - #30130

Merged
charris merged 1 commit into
numpy:maintenance/2.3.xfrom
charris:backport-30128
Nov 3, 2025
Merged

charris merged 1 commit into
numpy:maintenance/2.3.xfrom
charris:backport-30128

Conversation

charris commented Nov 3, 2025

Copy link
Copy Markdown
Member

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

….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
charris added this to the 2.3.5 release milestone Nov 3, 2025
charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Nov 3, 2025
charris merged commit 073cf79 into numpy:maintenance/2.3.x Nov 3, 2025
75 checks passed
charris deleted the backport-30128 branch November 3, 2025 00:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL