Use Windows system headers for POSIX read()/write()/getpid() (rebased #45)#63
Merged
Conversation
On Windows, read()/write() are declared in <io.h> and getpid() in <process.h>; 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 <windows.h>) along with its target_sources entry.
Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
01e20ef to
e8cb336
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
On Windows, the POSIX
read()/write()functions are declared in<io.h>andgetpid()in<process.h>. They are not pulled in by GKlib's Windows includepath, so modern Clang/clang-cl — which treat implicit declarations as hard
errors (
-Wimplicit-function-declaration) — fail to compilesrc/io.c:This is now reproduced by our own CI (the
clang-clNinja and-TClangCLMSBuild jobs) after the CI workflow was added in #46.
Change
__MSC__branch ofinclude/gk_arch.h, include<io.h>(declaresread/write) and<process.h>(declaresgetpid), andtypedef int pid_t;.win32/adapt.{c,h}shim, which existed only to provide agetpid()wrapper via<windows.h>;<process.h>supplies it directly. Theone in-tree
getpid()caller (src/memory.c) is unaffected.target_sourcesinCMakeLists.txt.Net
+4 / −30(a shim removal).Provenance
This is a rebased version of #45 by @MarijnS95, re-applied onto current
masterso it composes with the
_MSC_VER >= 1600stdint guard added by #59 and runsthrough the new CI. Original authorship preserved via
Co-authored-by.Validation
cmake -DNO_X86=ON): clean, 0 warnings / 0 errors — the#elsepath is untouched.io.cread/writeerrors should clear). Other compilers' pre-existing deprecation/ unused-variable warnings remain but are non-fatal.
Closes #45.