Skip to content

Check EX_OK is defined before including sysexits.h means it is always redefined #129539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
collinfunk opened this issue Feb 1, 2025 · 2 comments
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@collinfunk
Copy link
Contributor

collinfunk commented Feb 1, 2025

Bug report

Bug description:

Minor nit, but there is a check for the definition of EX_OK before sysexits.h is included. Meaning it is always redefined when that header exists.

  In file included from ./Modules/posixmodule.c:295:
  /usr/include/sysexits.h:92:9: warning: "EX_OK" redefined
     92 | #define EX_OK           0       /* successful termination */
        |         ^~~~~ 
  ./Modules/posixmodule.c:56:11: note: this is the location of the previous definition
     56 | #  define EX_OK EXIT_SUCCESS
      |           ^~~~~ 

The C standard says redefinition's like this aren't allowed, but in practice I've only seen compilers warn about them.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@collinfunk collinfunk added the type-bug An unexpected behavior, bug, or error label Feb 1, 2025
collinfunk added a commit to collinfunk/cpython that referenced this issue Feb 1, 2025
Previously the macro would be redefined when the header was included.
@picnixz picnixz added the extension-modules C modules in the Modules dir label Feb 1, 2025
collinfunk added a commit to collinfunk/cpython that referenced this issue Feb 1, 2025
Previously the macro would be redefined when the header was included.
collinfunk added a commit to collinfunk/cpython that referenced this issue Feb 1, 2025
Previously the macro would be redefined when the header was included.
vstinner added a commit to vstinner/cpython that referenced this issue Feb 1, 2025
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
vstinner added a commit to vstinner/cpython that referenced this issue Feb 1, 2025
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
vstinner added a commit to vstinner/cpython that referenced this issue Feb 1, 2025
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
vstinner added a commit that referenced this issue Feb 2, 2025
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
collinfunk added a commit to collinfunk/cpython that referenced this issue Feb 2, 2025
Previously the macro would be redefined when the header was included.
vstinner pushed a commit that referenced this issue Feb 2, 2025
Previously, the macro would be redefined when the header was included.
@vstinner
Copy link
Member

vstinner commented Feb 3, 2025

Fixed in 3.13 and main branch, the 3.12 backport is on going. Thanks for the fix and the bug report.

@vstinner vstinner closed this as completed Feb 3, 2025
vstinner added a commit that referenced this issue Feb 3, 2025
…129609)

[3.13] gh-129539: Include sysexits.h before checking EX_OK (#129590)

Previously, the macro would be redefined when the header was included.

(cherry picked from commit 65f3432)

Co-authored-by: Collin Funk <collin.funk1@gmail.com>
@collinfunk
Copy link
Contributor Author

Thanks for backporting it to 3.12 for me!

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Feb 7, 2025
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants