Skip to content

BUG: fix PyArray_ImportNumPyAPI under -Werror=strict-prototypes#26771

Merged
seberg merged 1 commit into
numpy:mainfrom
lpsinger:PyArray_ImportNumPyAPI-strict-prototypes
Jun 25, 2024
Merged

BUG: fix PyArray_ImportNumPyAPI under -Werror=strict-prototypes#26771
seberg merged 1 commit into
numpy:mainfrom
lpsinger:PyArray_ImportNumPyAPI-strict-prototypes

Conversation

@lpsinger
Copy link
Copy Markdown
Contributor

I was getting the following error in a code that includes the Numpy headers:

In file included from /opt/python/cp312-cp312/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:28,
                 from /opt/python/cp312-cp312/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
                 from cs_gamma.c:40:
/opt/python/cp312-cp312/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_2_compat.h:77:1: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
   77 | PyArray_ImportNumPyAPI()
      | ^~~~~~~~~~~~~~~~~~~~~~

In order to suppress this error, we change the declaration from

static inline int
PyArray_ImportNumPyAPI()

to

static inline int
PyArray_ImportNumPyAPI(void)

See example on Compiler Explorer (godbolt.org).

Complete the prototype of `PyArray_ImportNumPyAPI()` by adding
`void` to the argument list so that this header does not cause
errors when the user is compiling with `-Werror=strict-prototypes`.
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jun 20, 2024
@seberg
Copy link
Copy Markdown
Member

seberg commented Jun 25, 2024

Thanks @lpsinger.

@seberg seberg merged commit 594657d into numpy:main Jun 25, 2024
@lpsinger lpsinger deleted the PyArray_ImportNumPyAPI-strict-prototypes branch June 25, 2024 12:36
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 3, 2024
lalsuite-github-bot pushed a commit to lscsoft/lalsuite that referenced this pull request Jul 30, 2024
Remove workaround for numpy/numpy#26771,
which was merged and included in Numpy 2.0.1.
lalsuite-github-bot pushed a commit to lscsoft/lalsuite that referenced this pull request Apr 24, 2026
Remove workaround for numpy/numpy#26771,
which was merged and included in Numpy 2.0.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants