8000 gh-110079: Remove extern "C" { ...} in C code (#110080) · python/cpython@8b626a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b626a4

Browse files
authored
gh-110079: Remove extern "C" { ...} in C code (#110080)
1 parent bfd94ab commit 8b626a4

18 files changed

+6
-168
lines changed

Modules/_scproxy.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,8 @@ static struct PyModuleDef _scproxy_module = {
249249
.m_slots = _scproxy_slots,
250250
};
251251

252-
#ifdef __cplusplus
253-
extern "C" {
254-
#endif
255-
256252
PyMODINIT_FUNC
257253
PyInit__scproxy(void)
258254
{
259255
return PyModuleDef_Init(&_scproxy_module);
260256
}
261-
262-
#ifdef __cplusplus
263-
}
264-
#endif

Modules/_stat.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313

1414
#include "Python.h"
1515

16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2016
#ifdef HAVE_SYS_TYPES_H
2117
#include <sys/types.h>
2218
#endif /* HAVE_SYS_TYPES_H */
@@ -631,7 +627,3 @@ PyInit__stat(void)
631627
{
632628
return PyModuleDef_Init(&statmodule);
633629
}
634-
635-
#ifdef __cplusplus
636-
}
637-
#endif

Modules/main.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
"Type \"help\", \"copyright\", \"credits\" or \"license\" " \
2727
"for more information."
2828

29-
#ifdef __cplusplus
30-
extern "C" {
31-
#endif
32-
3329
/* --- pymain_init() ---------------------------------------------- */
3430

3531
static PyStatus
@@ -742,7 +738,3 @@ Py_BytesMain(int argc, char **argv)
742738
.wchar_argv = NULL};
743739
return pymain_main(&args);
744740
}
745-
746-
#ifdef __cplusplus
747-
}
748-
#endif

Modules/posixmodule.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@
222222
#endif
223223

224224

225-
#ifdef __cplusplus
226-
extern "C" {
227-
#endif
228-
229225
PyDoc_STRVAR(posix__doc__,
230226
"This module provides access to operating system functionality that is\n\
231227
standardized by the C Standard and the POSIX standard (a thinly\n\
@@ -17002,7 +16998,3 @@ INITFUNC(void)
1700216998
{
1700316999
return PyModuleDef_Init(&posixmodule);
1700417000
}
17005-
17006-
#ifdef __cplusplus
17007-
}
17008-
#endif

Objects/fileobject.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
#define NEWLINE_LF 2 /* \n newline seen */
2222
#define NEWLINE_CRLF 4 /* \r\n newline seen */
2323

24-
#ifdef __cplusplus
25-
extern "C" {
26-
#endif
27-
2824
/* External C interface */
2925

3026
PyObject *
@@ -539,8 +535,3 @@ _PyFile_Flush(PyObject *file)
539535
Py_DECREF(tmp);
540536
return 0;
541537
}
542-
543-
544-
#ifdef __cplusplus
545-
}
546-
#endif

Objects/object.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
# error "Py_LIMITED_API macro must not be defined"
2929
#endif
3030

31-
#ifdef __cplusplus
32-
extern "C" {
33-
#endif
34-
3531
/* Defined in tracemalloc.c */
3632
extern void _PyMem_DumpTraceback(int fd, const void *ptr);
3733

@@ -2808,7 +2804,3 @@ int Py_IsFalse(PyObject *x)
28082804
{
28092805
return Py_Is(x, Py_False);
28102806
}
2811-
2812-
#ifdef __cplusplus
2813-
}
2814-
#endif

Objects/unicodeobject.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ NOTE: In the interpreter's initialization phase, some globals are currently
100100
101101
*/
102102

103-
104-
#ifdef __cplusplus
105-
extern "C" {
106-
#endif
107-
108103
// Maximum code point of Unicode 6.0: 0x10ffff (1,114,111).
109104
// The value must be the same in fileutils.c.
110105
#define MAX_UNICODE 0x10ffff
@@ -15397,8 +15392,3 @@ PyInit__string(void)
1539715392
{
1539815393
return PyModuleDef_Init(&_string_module);
1539915394
}
15400-
15401-
15402-
#ifdef __cplusplus
15403-
}
15404-
#endif

Python/dtoa.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ typedef uint64_t ULLong;
172172
#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
173173
#endif
174174

175-
#ifdef __cplusplus
176-
extern "C" {
177-
#endif
178-
179175
typedef union { double d; ULong L[2]; } U;
180176

181177
#ifdef IEEE_8087
@@ -2813,8 +2809,5 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
28132809
_Py_dg_freedtoa(s0);
28142810
return NULL;
28152811
}
2816-
#ifdef __cplusplus
2817-
}
2818-
#endif
28192812

28202813
#endif // _PY_SHORT_FLOAT_REPR == 1

Python/errors.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
# include <stdlib.h> // _sys_nerr
1717
#endif
1818

19-
20-
#ifdef __cplusplus
21-
extern "C" {
22-
#endif
23-
2419
/* Forward declarations */
2520
static PyObject *
2621
_PyErr_FormatV(PyThreadState *tstate, PyObject *exception,
@@ -1918,7 +1913,3 @@ PyErr_ProgramTextObject(PyObject *filename, int lineno)
19181913
{
19191914
return _PyErr_ProgramDecodedTextObject(filename, lineno, NULL);
19201915
}
1921-
1922-
#ifdef __cplusplus
1923-
}
1924-
#endif

Python/getargs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#include "pycore_pylifecycle.h" // _PyArg_Fini
88
#include "pycore_tuple.h" // _PyTuple_ITEMS()
99

10-
#ifdef __cplusplus
11-
extern "C" {
12-
#endif
13-
1410
/* Export Stable ABIs (abi only) */
1511
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
1612
PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
@@ -2867,7 +2863,3 @@ _PyArg_Fini(void)
28672863
}
28682864
_PyRuntime.getargs.static_parsers = NULL;
28692865
}
2870-
2871-
#ifdef __cplusplus
2872-
};
2873-
#endif

Python/getopt.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
#include <wchar.h>
3030
#include "pycore_getopt.h"
3131

32-
#ifdef __cplusplus
33-
extern "C" {
34-
#endif
35-
3632
int _PyOS_opterr = 1; /* generate error messages */
3733
Py_ssize_t _PyOS_optind = 1; /* index into argv array */
3834
const wchar_t *_PyOS_optarg = NULL; /* optional argument */
@@ -172,8 +168,3 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
172168

173169
return option;
174170
}
175-
176-
#ifdef __cplusplus
177-
}
178-
#endif
179-

Python/import.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#ifdef HAVE_FCNTL_H
2525
#include <fcntl.h>
2626
#endif
27-
#ifdef __cplusplus
28-
extern "C" {
29-
#endif
3027

3128

3229
/*[clinic input]
@@ -3887,8 +3884,3 @@ PyInit__imp(void)
38873884
{
38883885
return PyModuleDef_Init(&imp_module);
38893886
}
3890-
3891-
3892-
#ifdef __cplusplus
3893-
}
3894-
#endif

Python/pathconfig.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
# include <shlwapi.h>
1717
#endif
1818

19-
#ifdef __cplusplus
20-
extern "C" {
21-
#endif
22-
2319

2420
/* External interface */
2521

@@ -500,8 +496,3 @@ _PyPathConfig_ComputeSysPath0(const PyWideStringList *argv, PyObject **path0_p)
500496
*path0_p = path0_obj;
501497
return 1;
502498
}
503-
504-
505-
#ifdef __cplusplus
506-
}
507-
#endif

Python/pyhash.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# include <sys/endian.h>
1515
#endif
1616

17-
#ifdef __cplusplus
18-
extern "C" {
19-
#endif
20-
2117
_Py_HashSecret_t _Py_HashSecret = {{0}};
2218

2319
#if Py_HASH_ALGORITHM == Py_HASH_EXTERNAL
@@ -503,7 +499,3 @@ pysiphash(const void *src, Py_ssize_t src_sz) {
503499

504500
static PyHash_FuncDef PyHash_Func = {pysiphash, "siphash24", 64, 128};
505501
#endif
506-
507-
#ifdef __cplusplus
508-
}
509-
#endif

Python/pylifecycle.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161
#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str))
6262

6363

64-
#ifdef __cplusplus
65-
extern "C" {
66-
#endif
67-
68-
6964
/* Forward declarations */
7065
static PyStatus add_main_module(PyInterpreterState *interp);
7166
static PyStatus init_import_site(void);
@@ -3139,7 +3134,3 @@ PyOS_setsig(int sig, PyOS_sighandler_t handler)
31393134
return oldhandler;
31403135
#endif
31413136
}
3142-
3143-
#ifdef __cplusplus
3144-
}
3145-
#endif

Python/pystate.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,12 @@ to avoid the expense of doing their own locking).
2929
-------------------------------------------------------------------------- */
3030

3131
#ifdef HAVE_DLOPEN
32-
#ifdef HAVE_DLFCN_H
33-
#include <dlfcn.h>
34-
#endif
35-
#if !HAVE_DECL_RTLD_LAZY
36-
#define RTLD_LAZY 1
37-
#endif
38-
#endif
39-
40-
#ifdef __cplusplus
41-
extern "C" {
32+
# ifdef HAVE_DLFCN_H
33+
# include <dlfcn.h>
34+
# endif
35+
# if !HAVE_DECL_RTLD_LAZY
36+
# define RTLD_LAZY 1
37+
# endif
4238
#endif
4339

4440

@@ -2985,8 +2981,3 @@ _PyThreadState_MustExit(PyThreadState *tstate)
29852981
}
29862982
return 1;
29872983
}
2988-
2989-
2990-
#ifdef __cplusplus
2991-
}
2992-
#endif

Python/pythonrun.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
# include "windows.h"
3838
#endif
3939

40-
41-
#ifdef __cplusplus
42-
extern "C" {
43-
#endif
44-
4540
/* Forward */
4641
static void flush_io(void);
4742
static PyObject *run_mod(mod_ty, PyObject *, PyObject *, PyObject *,
@@ -2017,7 +2012,3 @@ PyRun_InteractiveLoop(FILE *f, const char *p)
20172012
{
20182013
return PyRun_InteractiveLoopFlags(f, p, NULL);
20192014
}
2020-
2021-
#ifdef __cplusplus
2022-
}
2023-
#endif

Python/sysmodule.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,11 +2039,6 @@ sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs)
20392039
return _PyEval_CallTracing(func, funcargs);
20402040
}
20412041

2042-
2043-
#ifdef __cplusplus
2044-
extern "C" {
2045-
#endif
2046-
20472042
/*[clinic input]
20482043
sys._debugmallocstats
20492044
@@ -2072,10 +2067,6 @@ sys__debugmallocstats_impl(PyObject *module)
20722067
extern PyObject *_Py_GetObjects(PyObject *, PyObject *);
20732068
#endif
20742069

2075-
#ifdef __cplusplus
2076-
}
2077-
#endif
2078-
20792070

20802071
/*[clinic input]
20812072
sys._clear_type_cache
@@ -2297,11 +2288,6 @@ sys__getframemodulename_impl(PyObject *module, int depth)
22972288
return Py_NewRef(r);
22982289
}
22992290

2300-
2301-
#ifdef __cplusplus
2302-
extern "C" {
2303-
#endif
2304-
23052291
static PerfMapState perf_map_state;
23062292

23072293
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void) {
@@ -2370,10 +2356,6 @@ PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void) {
23702356
#endif
23712357
}
23722358

2373-
#ifdef __cplusplus
2374-
}
2375-
#endif
2376-
23772359

23782360
static PyMethodDef sys_methods[] = {
23792361
/* Might as well keep this in alphabetic order */

0 commit comments

Comments
 (0)
0