cpython
cpython copied to clipboard
gh-94795: Remove `#ifdef __cplusplus` from C-only code
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: https://github.com/python/cpython/blob/cceac5dd06fdbaba3f45b8be159dfa79b74ff237/Python/getcompiler.c#L15-L19
- Issue: gh-94795
Does this solve an issue? We don't generally do style-only changes.
~~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).
IIRC, @gpshead & @Yhg1s have had some interest in this ifdef in the past.
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
Closing because nobody evaluated the change as non-cosmetical.