Commit 1e424da
authored
BUG: Avoid compilation error of wrapper file generated with SWIG >= 4.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#301221 parent a8546b7 commit 1e424da
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
167 | | - | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
0 commit comments