From dfd3c9a8237180a5456a13ecc3c1e19cb52ccd1a Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Sun, 12 Jan 2025 10:37:29 +0530
Subject: [PATCH 24/25] Do not define pid_t as it might conflict with the
 actual definition

---
 Modules/_testcapi/long.c        | 4 ++++
 Modules/_testcapimodule.c       | 4 ++++
 Modules/_testlimitedcapi/long.c | 4 ++++
 Modules/clinic/posixmodule.c.h  | 4 ++++
 Modules/posixmodule.c           | 1 +
 PC/pyconfig.h                   | 2 --
 Python/remote_debug.h           | 3 +++
 7 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Modules/_testcapi/long.c b/Modules/_testcapi/long.c
index 6313abf5485..bc8169e2f68 100644
--- a/Modules/_testcapi/long.c
+++ b/Modules/_testcapi/long.c
@@ -6,6 +6,10 @@
 #include "util.h"
 #include "clinic/long.c.h"
 
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
 /*[clinic input]
 module _testcapi
 [clinic start generated code]*/
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 2572df9719a..792c0df35af 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -23,6 +23,10 @@
 #  include <sys/wait.h>           // W_STOPCODE
 #endif
 
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
 #ifdef bool
 #  error "The public headers should not include <stdbool.h>, see gh-48924"
 #endif
diff --git a/Modules/_testlimitedcapi/long.c b/Modules/_testlimitedcapi/long.c
index 34bc7331da9..abae4b19bf0 100644
--- a/Modules/_testlimitedcapi/long.c
+++ b/Modules/_testlimitedcapi/long.c
@@ -8,6 +8,10 @@
 #include "util.h"
 #include "clinic/long.c.h"
 
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
 /*[clinic input]
 module _testlimitedcapi
 [clinic start generated code]*/
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 87a17935507..a88a9151cb6 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -10,6 +10,10 @@ preserve
 #include "pycore_long.h"          // _PyLong_UnsignedInt_Converter()
 #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
 
+#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM))
+typedef int pid_t;
+#endif
+
 PyDoc_STRVAR(os_stat__doc__,
 "stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n"
 "--\n"
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e1576f809fa..1ea521478e7 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -219,6 +219,7 @@
 #  if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
 #    define HAVE_SYMLINK
 #  endif /* MS_WINDOWS_DESKTOP | MS_WINDOWS_SYSTEM */
+typedef int pid_t;
 #endif
 
 
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index 710a737ebcc..92d327b1e35 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -235,8 +235,6 @@ typedef _W64 int Py_ssize_t;
 #endif
 #endif /* MS_WIN32 && !MS_WIN64 */
 
-typedef int pid_t;
-
 /* define some ANSI types that are not defined in earlier Win headers */
 #if _MSC_VER >= 1200
 /* This file only exists in VC 6.0 or higher */
diff --git a/Python/remote_debug.h b/Python/remote_debug.h
index 8f9b6cd4c49..20cd65dd818 100644
--- a/Python/remote_debug.h
+++ b/Python/remote_debug.h
@@ -28,6 +28,9 @@ extern "C" {
 #endif
 
 #include "pyconfig.h"
+#ifdef _WIN32
+typedef int pid_t;
+#endif
 #include "internal/pycore_ceval.h"
 
 #ifdef __linux__
