Skip to content

Compiler warnings with -Wundef. #29138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
charris opened this issue Jun 7, 2025 · 0 comments
Open

Compiler warnings with -Wundef. #29138

charris opened this issue Jun 7, 2025 · 0 comments

Comments

@charris
Copy link
Member

charris commented Jun 7, 2025

We are using undefined macros in several places.

[56/359] Compiling C object numpy/_core/_struct_ufunc_tests.cpython-313-x86_64-linux-gnu.so.p/src_umath__struct_ufunc_tests.c.o
../numpy/_core/src/umath/_struct_ufunc_tests.c: In function ‘PyInit__struct_ufunc_tests’:
../numpy/_core/src/umath/_struct_ufunc_tests.c:160:5: warning: ‘Py_GIL_DISABLED’ is not defined, evaluates to ‘0’ [-Wundef]
  160 | #if Py_GIL_DISABLED
      |     ^~~~~~~~~~~~~~~

many places. This is a choice by Python to not define the macro for builds without free threading, but we might want to put a guard on it just to avoid the noise.

../numpy/_core/include/numpy/npy_common.h:504:20: warning: ‘NPY_ULONG’ is not defined, evaluates to ‘0’ [-Wundef]
  504 | #define NPY_UINT64 NPY_ULONG
      |                    ^~~~~~~~~
../numpy/_core/src/multiarray/descriptor.c:2098:22: note: in expansion of macro ‘NPY_UINT64’
 2098 | #if NPY_ULONGLONG == NPY_UINT64
      |                      ^~~~~~~~~~

Probably came about when we dropped the old header. Should be defined in numpyconfig.h

[352/359] Compiling C object numpy/random/_common.cpython-313-x86_64-linux-gnu.so.p/meson-generated_numpy_random__common.pyx.c.o
numpy/random/_common.cpython-313-x86_64-linux-gnu.so.p/numpy/random/_common.pyx.c:2814:35: warning: ‘CYTHON_PROFILE’ is not defined, evaluates to ‘0’ [-Wundef]
 2814 | #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)

Probably a Cython choice not to define the macro.

Also in a test:

limited_api_latest.c:1:23: error: ‘PY_VERSION_HEX’ is not defined, evaluates to ‘0’ [-Werror=undef]
    1 | #if Py_LIMITED_API != PY_VERSION_HEX & 0xffff0000
      |                       ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Probably failure to import Python.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant