Skip to content

[C API] Build Python with -Wundef to detect typos in C macro names and detect undefined macros #162214

Open
0 of 1 issue completed

Description

@vstinner

Bug report

When using #ifdef MACRO or #if defined(MACRO), the C preprocessor ignores silently error if the MACRO is not defined. If there is a typo in the macro name, it's ignored silently.

I propose building Python with -Wundef (when it's supported by the C compiler) to detect usage of undefined macros.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. vstinner commented on Nov 18, 2026

    @vstinner
    MemberAuthor

    See commit de9a4fb for a recent example of such issue: _Py_STDC_VERSION macro was used whereas the macro was unused. The change modified test_cext to build the C and C++ extensions with -Wundef.

  2. added 8 commits that reference this issue on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions