Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Compiler warnings with -Wundef. #29138

Closed
@charris

Description

@charris

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions