-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
According to issue 44426 reported on bugs.python.org, Sphinx 4.0.2 fails to build the current Python documentation (when warnings are being treated as errors) as a result of this warning:
Warning, treated as error:
/builddir/build/BUILD/Python-3.10.0b2/Doc/c-api/complex.rst:49:Error in declarator or parameters
Error in declarator or parameters
Invalid C declaration: Expected identifier, got keyword: complex [error at 39]
Py_complex _Py_c_neg(Py_complex complex)
---------------------------------------^
make: *** [Makefile:51: build] Error 2
This issue has been worked around in the CPython source, by changing the name complex
to num
. Nevertheless, I think Sphinx is being too strict here, and the error message is incorrect: complex
is not a C keyword. If complex.h
has been included, then complex
is a macro that expands to a C keyword, but that's not the same thing, and there's plenty of code out there that doesn't include complex.h
(CPython doesn't include complex.h
at any point, for example) and may still want to use complex
as a C variable name.
Both gcc and clang are happy for complex
to be used as a variable name, and don't issue any warning:
mdickinson@mirzakhani Desktop % cat test.c
typedef struct {
double real;
double imag;
} Py_complex;
Py_complex _Py_c_neg(Py_complex complex);
mdickinson@mirzakhani Desktop % gcc -Wall -Wextra -std=c17 -c test.c
mdickinson@mirzakhani Desktop % clang -Wall -Wextra -std=c17 -c test.c
mdickinson@mirzakhani Desktop %