From e8cb336ef5bc67dedc8e008f3ba3df7ac9555213 Mon Sep 17 00:00:00 2001 From: George Karypis Date: Sat, 30 May 2026 13:55:46 -0500 Subject: [PATCH] Use Windows system headers for POSIX read()/write()/getpid() (#45) On Windows, read()/write() are declared in and getpid() in ; modern Clang/clang-cl treat the missing declarations as hard errors (-Wimplicit-function-declaration), breaking src/io.c. Include those headers in the __MSC__ branch of gk_arch.h and drop the bundled win32/adapt.{c,h} shim (which only wrapped getpid() via ) along with its target_sources entry. Co-authored-by: Marijn Suijten Co-Authored-By: Claude Opus 4.8 (1M context) --- CMakeLists.txt | 5 +---- include/gk_arch.h | 4 +++- include/win32/adapt.h | 14 -------------- src/win32/adapt.c | 11 ----------- 4 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 include/win32/adapt.h delete mode 100644 src/win32/adapt.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e87970a..cc386c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,10 +78,7 @@ target_sources(${PROJECT_NAME} include/gk_mkpqueue2.h include/gk_mkrandom.h include/gk_mksort.h include/gk_mkutils.h include/gk_proto.h include/gk_struct.h include/gk_types.h include/gkregex.h include/gk_ms_inttypes.h - include/gk_ms_stat.h include/gk_ms_stdint.h - # the following are shims for win32 systems - $<$:src/win32/adapt.c - include/win32/adapt.h>) + include/gk_ms_stat.h include/gk_ms_stdint.h) target_compile_definitions(${PROJECT_NAME} PUBLIC $<$:LINUX> diff --git a/include/gk_arch.h b/include/gk_arch.h index 0f04491..b5b290b 100644 --- a/include/gk_arch.h +++ b/include/gk_arch.h @@ -41,7 +41,9 @@ #include "gk_ms_inttypes.h" #endif #include "gk_ms_stat.h" - #include "win32/adapt.h" + #include + #include + typedef int pid_t; #else #ifndef SUNOS #include diff --git a/include/win32/adapt.h b/include/win32/adapt.h deleted file mode 100644 index 35e60ed..0000000 --- a/include/win32/adapt.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -\file win32/adapt.h -\brief Declaration of Win32 adaptation of POSIX functions and types -*/ -#ifndef _WIN32_ADAPT_H_ -#define _WIN32_ADAPT_H_ - -#include - -typedef DWORD pid_t; - -pid_t getpid(void); - -#endif /* _WIN32_ADAPT_H_ */ diff --git a/src/win32/adapt.c b/src/win32/adapt.c deleted file mode 100644 index 546857c..0000000 --- a/src/win32/adapt.c +++ /dev/null @@ -1,11 +0,0 @@ -/* -\file win32/adapt.c -\brief Implementation of Win32 adaptation of libc functions -*/ - -#include "adapt.h" - -pid_t getpid(void) -{ - return GetCurrentProcessId(); -}