Commit 9a77023ffe31da98eb1dafbefe005171d1ef7499

Michael Haubenwallner 2019-08-22T16:55:44

build: Use <unistd.h> only if available Some target platforms do not have <unistd.h>, notably Windows when using vanilla MSVC toolchain. Note: The AC_CHECK_HEADERS([unistd.h]) is redundant with LT_INIT, but there is no guarantee for that. [guillem@hadrons.org: - Use AC_CHECK_HEADERS instead of AC_CHECK_HEADER. - Quote argument to AC_CHECK_HEADERS. ] Signed-off-by: Guillem Jover <guillem@hadrons.org>

diff --git a/configure.ac b/configure.ac
index f029dc1..a5e30b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@ AC_PROG_CC
 # Checks for libraries.
 
 # Checks for header files.
+AC_CHECK_HEADERS([unistd.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_BIGENDIAN
diff --git a/src/helper.c b/src/helper.c
index 2a06503..91a8973 100644
--- a/src/helper.c
+++ b/src/helper.c
@@ -18,7 +18,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 #include <hashinc>