X Tutup
The Wayback Machine - https://web.archive.org/web/20250527201134/https://github.com/python/cpython/pull/94796
Skip to content

gh-94795: Remove #ifdef __cplusplus from C-only code #94796

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
wants to merge 11 commits into from

Conversation

arhadthedev
Copy link
Member

@arhadthedev arhadthedev commented Jul 13, 2022

The PR contains one-type replacements so I don't know how to split them into smaller PRs.

Edit: also removed a dead branch from:

#elif defined(__cplusplus)
#define COMPILER "[C++]"
#else
#define COMPILER "[C]"
#endif

@brettcannon brettcannon removed their request for review July 13, 2022 18:08
@encukou
Copy link
Member

encukou commented Jul 14, 2022

Does this solve an issue?
We don't generally do style-only changes.

@arhadthedev
Copy link
Member Author

arhadthedev commented Jul 14, 2022

I believe that multiple repetitions of the same dead and slightly confusing code is worth deleting.

Hovewer, I agree that it has no maintanance burden so the PR brings no functional change.

Edit: The removed code is dead (C compilers never ever declare __cplusplus) so it may confuse a reader whether there's some arcane inclusion from C++ code.

Edit2: just in case, here's an answer from a linked issue:

It brings confusion and doubts. For example, if a .c file has a C++-specific guard, it likely means some hacky compilation as C++. So to not to tease contributors with groundless questions, it's better to remove the offending parts (27 files total plus getcompiler.c with never used version of COMPILER macro).

@ericsnowcurrently
Copy link
Member

IIRC, @gpshead & @Yhg1s have had some interest in this ifdef in the past.

@arhadthedev
Copy link
Member Author

I restored all *.h files back because CPython has a few C++ modules so even private headers must be aware of them.

To reiterate, currently this PR removes chunks of totally dead code because __cplusplus is never defined for *.c files

@arhadthedev
Copy link
Member Author

Closing because nobody evaluated the change as non-cosmetical.

@arhadthedev arhadthedev closed this Feb 3, 2023
@arhadthedev arhadthedev deleted the remove-dotc-__cplusplus branch February 3, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
X Tutup