[PATCH 3/3] Use unistd.h only if available

Michael Haubenwallner michael.haubenwallner at ssi-schaefer.com
Thu Aug 22 14:55:44 UTC 2019


Some target platforms do not have unistd.h, notably Windows when using
vanilla MSVC toolchain.  Note: The AC_CHECK_HEADER(unistd.h) is
redundant with LT_INIT, but there is no guarantee for that.
---
 configure.ac | 1 +
 src/helper.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/configure.ac b/configure.ac
index f029dc1..dc340fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@ AC_PROG_CC
 # Checks for libraries.
 
 # Checks for header files.
+AC_CHECK_HEADER(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>
 
-- 
2.21.0



More information about the libbsd mailing list