Fix macOS build: include unistd.h in zlib's gzguts.h for lseek declaration #2
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.
Problem
The build on macOS was failing with an undeclared identifier error for
lseekinLibraries/zlib/Source/gzlib.c. This occurred because the vendored zlib dependency'sgzguts.hheader file did not include<unistd.h>for non-Windows platforms, where thelseekfunction is declared.The
gzlib.cfile uses theLSEEKmacro which expands tolseekon non-Windows platforms:While
zconf.hconditionally includes<unistd.h>, it only does so when_LARGEFILE64_SOURCEis defined. On macOS, this condition may not be met, leavinglseekundeclared.Solution
Added
#include <unistd.h>toLibraries/zlib/Include/gzguts.hfor non-Windows platforms:This ensures that POSIX file operations like
lseekare properly declared before being used, regardless of whether large file support macros are defined.Testing
lseekis properly declared in preprocessor output_WIN32is defined)This is a minimal, surgical fix that only affects non-Windows platforms and should resolve the macOS build failures without any side effects.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.