--- a/unix/configure
+++ b/unix/configure
@@ -382,7 +382,7 @@ $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
 for func in fchmod fchown lchown nl_langinfo
 do
   echo Check for $func
-  echo "int main(){ $func(); return 0; }" > conftest.c
+  echo "void $func(); int main(){ $func(); return 0; }" > conftest.c
   $CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
   [ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
 done
@@ -401,14 +401,18 @@ ln -s "${temp_link}" "${temp_file}" && \
 rm -f "${temp_file}"
 
 echo Check for memset
-echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
+cat > conftest.c << _EOF_
+#include <string.h>
+int main(){ char k; memset(&k,0,0); return 0; }
+_EOF_
+
 $CC -o conftest conftest.c >/dev/null 2>/dev/null
 [ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DZMEM"
 
 echo Check for errno declaration
 cat > conftest.c << _EOF_
 #include <errno.h>
-main()
+int main()
 {
   errno = 0;
   return 0;
@@ -419,6 +423,8 @@ $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
 
 echo Check for directory libraries
 cat > conftest.c << _EOF_
+#include <sys/types.h>
+#include <dirent.h>
 int main() { return closedir(opendir(".")); }
 _EOF_
 
@@ -439,7 +445,11 @@ fi
 
 # Dynix/ptx 1.3 needed this
 echo Check for readlink
-echo "int main(){ return readlink(); }" > conftest.c
+cat > conftest.c << _EOF_
+#include <unistd.h>
+int main(){ return readlink(); }
+_EOF_
+
 $CC -o conftest conftest.c >/dev/null 2>/dev/null
 if [ $? -ne 0 ]; then
   $CC -o conftest conftest.c -lseq >/dev/null 2>/dev/null
@@ -523,7 +533,8 @@ fi
 # needed for AIX (and others ?) when mmap is used
 echo Check for valloc
 cat > conftest.c << _EOF_
-main()
+#include <stdlib.h>
+int main()
 {
 #ifdef MMAP
     valloc();
