Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python 3.11 C API is not compatible with ISO C90: ISO C90 forbids mixed declarations and code #92781

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@vstinner

Description

@vstinner

On Fedora, building the xen package with Python 3.11 fails with C compiler errors like:

In file included from /usr/include/python3.11/unicodeobject.h:1042,                 from /usr/include/python3.11/Python.h:51,                 from xen/lowlevel/xc/xc.c:7:/usr/include/python3.11/cpython/unicodeobject.h: In function ‘_PyUnicode_NONCOMPACT_DATA’:/usr/include/python3.11/cpython/unicodeobject.h:330:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]  330 |     void *data = _PyUnicodeObject_CAST(op)->data.any;      |     ^~~~/usr/include/python3.11/cpython/unicodeobject.h: In function ‘PyUnicode_READ_CHAR’:/usr/include/python3.11/cpython/unicodeobject.h:414:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]  414 |     unsigned int kind = PyUnicode_KIND(unicode);      |     ^~~~~~~~/usr/include/python3.11/cpython/unicodeobject.h: In function ‘PyUnicode_MAX_CHAR_VALUE’:/usr/include/python3.11/cpython/unicodeobject.h:439:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]  439 |     unsigned int kind = PyUnicode_KIND(op);      |     ^~~~~~~~In file included from /usr/include/python3.11/weakrefobject.h:35,                 from /usr/include/python3.11/Python.h:83:/usr/include/python3.11/cpython/weakrefobject.h: In function ‘PyWeakref_GET_OBJECT’:/usr/include/python3.11/cpython/weakrefobject.h:41:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]   41 |     PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);      |     ^~~~~~~~~~~~~~~In file included from /usr/include/python3.11/abstract.h:866,                 from /usr/include/python3.11/Python.h:100:/usr/include/python3.11/cpython/abstract.h: In function ‘PyObject_CallMethodOneArg’:/usr/include/python3.11/cpython/abstract.h:116:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]  116 |     size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;      |     ^~~~~~/usr/include/python3.11/cpython/abstract.h: In function ‘_PyObject_CallMethodIdOneArg’:/usr/include/python3.11/cpython/abstract.h:165:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]  165 |     size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;      |     ^~~~~~cc1: all warnings being treated as errors

See:https://bugzilla.redhat.com/show_bug.cgi?id=2084008#c0

In Python 3.11, PEP 670 converts multiple macros to static inline functions. A C11 compiler (without optional features) is now required to build Python 3.11.

In 2022, most C compilers support C99 which supports mixed declarations and code, so I don't understand why people insist on using-Werror=declaration-after-statement. Maybe it's more a coding style, than a technical requirement. Or maybe it prevented compiler errors on old C compilers a few years ago, and nobody considered removing the compiler flag since that old time.

We can try to stay somehow compatible with ISO C90 in Python 3.11. Avoid "mixed declarations and code" in static inline functions requires minimum changes and so IMO is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp