Skip to content

BUG: Use of #undef complex in npy_common.h breaks extension modules that use #include <complex.h> #24344

@WarrenWeckesser

Description

@WarrenWeckesser

Describe the issue:

The line #undef complex in the file npy_common.h that was added in #24085 breaks the compilation of any extension module that uses both npy_common.h and the standard header <complex.h>. (See, for example, the extension module cross_gufunc.c.src in ufunclab.)

A fix would be to remove that line from npy_common.h, but that will break any code that the includes npy_common.h that also uses the name complex to define a variable or struct. This is the case for several files in NumPy, including the f2c-related files in the lapack_lite code (see my naive attempt in #24343).

Transitive includes and the global namespace in C... such fun.

Runtime information:

In [1]: import sys, numpy; print(numpy.__version__); print(sys.version)
2.0.0.dev0+766.g8627dc962
3.11.1 (v3.11.1:a7a450f84a, Dec  6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)]

In [2]: print(numpy.show_runtime())
[{'numpy_version': '2.0.0.dev0+766.g8627dc962',
  'python': '3.11.1 (v3.11.1:a7a450f84a, Dec  6 2022, 15:24:06) [Clang 13.0.0 '
            '(clang-1300.0.29.30)]',
  'uname': uname_result(system='Darwin', node='Warrens-MacBook-Air.local', release='22.5.0', version='Darwin Kernel Version 22.5.0: Thu Jun  8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112', machine='arm64')},
 {'simd_extensions': {'baseline': [], 'found': [], 'not_found': []}}]
None

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions