]> git.ipfire.org Git - thirdparty/zstd.git/commit
Fix the c99/cmake build under Cygwin/MSYS2
authorChristoph Reiter <reiter.christoph@gmail.com>
Sat, 11 Jan 2020 00:04:14 +0000 (01:04 +0100)
committerChristoph Reiter <reiter.christoph@gmail.com>
Sat, 11 Jan 2020 00:39:10 +0000 (01:39 +0100)
commitddd4c39736a0960ba466632cbf8cf76ceb2c59bc
treeb292760b13f856f3c11b95db732b5efd20360991
parentd1cc9d279704057c08ab976618c8bd629bc18f7e
Fix the c99/cmake build under Cygwin/MSYS2

When building zst under cygwin or msys2 with std=c99 the build would fail because
of an undefined fileno()/_fileno(), which is used by the IS_CONSOLE() macro.

When building with -std=c99 (gcc otherwise defaults to gnu, which implies POSIX),
which is the default of the cmake build, then including unistd.h wont define
_POSIX_VERSION and all other headers also wont expose POSIX API.

To fix this make sure to define _POSIX_C_SOURCE with the version we want before including
unistd.h and so that _POSIX_VERSION is set to the version provided by the system.

Since Cygwin/MSYS2 just follow POSIX we can also remove their special cases for
defining IS_CONSOLE().

And, for completeness, also explicitly include stdio.h which is what actually declares fileno().

Tested with the normal make file and cmake under MSYS2 and Cygwin.
programs/platform.h