Describe the bug
We're trying to migrate to using C11 on NumPy on numpy/numpy#25072, but compilation of some Cython code handling complex numbers fails. It probably has to do with https://github.com/cython/cython/blob/master/Cython/Utility/Complex.c#L7, where C11 is being checked, but without also checking for MSVC at the same time. This leads to using MSVC complex types (_Fcomplex etc.), for which there's no proper support.
The following (untested) diff should probably fix this:
diff --git a/Cython/Utility/Complex.c b/Cython/Utility/Complex.c
index a9b851288..85f47c7bf 100644
--- a/Cython/Utility/Complex.c
+++ b/Cython/Utility/Complex.c
@@ -4,7 +4,7 @@
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
- #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__))
+ #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(_MSC_VER)) && !defined(__STDC_NO_COMPLEX__))
// <complex.h> should exist since C99, but only C11 defines a test to detect it.
// MSVC defines "_Complex_I" but not "_Complex". See https://github.com/cython/cython/issues/5512
#define CYTHON_CCOMPLEX 1
If you agree with the solution, I can open a PR!
Expected behaviour
No compilation failures.
OS
Windows
Python version
3.11.6
Cython version
3.0.5
Describe the bug
We're trying to migrate to using C11 on NumPy on numpy/numpy#25072, but compilation of some Cython code handling complex numbers fails. It probably has to do with https://github.com/cython/cython/blob/master/Cython/Utility/Complex.c#L7, where C11 is being checked, but without also checking for MSVC at the same time. This leads to using MSVC complex types (
_Fcomplexetc.), for which there's no proper support.The following (untested) diff should probably fix this:
If you agree with the solution, I can open a PR!
Expected behaviour
No compilation failures.
OS
Windows
Python version
3.11.6
Cython version
3.0.5