cpython icon indicating copy to clipboard operation
cpython copied to clipboard

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

Open arhadthedev opened this issue 3 years ago • 3 comments

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

arhadthedev avatar Jul 13 '22 05:07 arhadthedev

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

encukou avatar Jul 14 '22 09:07 encukou

~~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).

arhadthedev avatar Jul 14 '22 11:07 arhadthedev

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

ericsnowcurrently avatar Sep 26 '22 17:09 ericsnowcurrently

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 avatar Jan 26 '23 10:01 arhadthedev

Closing because nobody evaluated the change as non-cosmetical.

arhadthedev avatar Feb 03 '23 12:02 arhadthedev