Skip to content

Commit 717c3cb

Browse files
authored
Merge pull request #98 from hattne/unistd
Guard inclusion of unistd.h
2 parents 567cf8f + 7b75ce4 commit 717c3cb

22 files changed

+61
-34
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ if (NOT CMAKE_BUILD_TYPE)
337337
endif (NOT CMAKE_BUILD_TYPE)
338338

339339

340+
# Check for missing header files.
341+
include(CheckIncludeFile)
342+
check_include_file("unistd.h" HAVE_UNISTD_H)
343+
if(HAVE_UNISTD_H)
344+
add_compile_definitions("HAVE_UNISTD_H")
345+
endif()
346+
347+
340348
# Check for missing functions: fgetln(3) is in 4.4BSD; realpath(3) is
341349
# in 4.4BSD, POSIX.1-2001; regcomp(3) is in POSIX.1-2001,
342350
# POSIX.1-2008.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,9 @@ endif
731731
CC = gcc
732732
C++ = g++
733733
ifneq ($(CBFDEBUG),)
734-
CFLAGS = -g -O0 -Wall -DHAVE_REALPATH -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DCBFDEBUG=1 $(HDF5CFLAGS)
734+
CFLAGS = -g -O0 -Wall -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DHAVE_REALPATH -DCBFDEBUG=1 -DHAVE_UNISTD_H $(HDF5CFLAGS)
735735
else
736-
CFLAGS = -g -O3 -Wall -DHAVE_REALPATH -D_USE_XOPEN_EXTENDED -fno-strict-aliasing $(HDF5CFLAGS)
736+
CFLAGS = -g -O3 -Wall -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DHAVE_REALPATH -DHAVE_UNISTD_H $(HDF5CFLAGS)
737737
endif
738738
LDFLAGS =
739739
F90C = gfortran

Makefile_LINUX

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ endif
730730
#########################################################
731731
CC = gcc
732732
C++ = g++
733-
CFLAGS = -g -O2 -Wall -DHAVE_REALPATH -D_USE_XOPEN_EXTENDED -fno-strict-aliasing $(HDF5CFLAGS)
733+
CFLAGS = -g -O2 -Wall -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DHAVE_REALPATH -DHAVE_UNISTD_H $(HDF5CFLAGS)
734734
LDFLAGS =
735735
F90C = gfortran
736736
#F90FLAGS = -g -fno-range-check -fallow-invalid-boz

Makefile_MINGW

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ endif
732732
#########################################################
733733
CC = gcc
734734
C++ = g++
735-
CFLAGS = -g -O2 -Wall -I/usr/include -fno-strict-aliasing $(HDF5CFLAGS)
735+
CFLAGS = -g -O2 -Wall -I/usr/include -fno-strict-aliasing -DHAVE_UNISTD_H $(HDF5CFLAGS)
736736
LDFLAGS =
737737
F90C = g95
738738
F90FLAGS = -g

Makefile_MSYS2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ endif
731731
CC = gcc
732732
C++ = g++
733733
CFLAGS = -g -O2 -Wall -D_USE_XOPEN_EXTENDED -DH5_HAVE_WIN32_API \
734-
-DH5_HAVE_MINGW -DH5_USE_110_API -fno-strict-aliasing $(HDF5CFLAGS)
734+
-DH5_HAVE_MINGW -DH5_USE_110_API -fno-strict-aliasing -DHAVE_UNISTD_H \
735+
$(HDF5CFLAGS)
735736
LDFLAGS =
736737
F90C = gfortran
737738
#F90FLAGS = -g -fno-range-check -fallow-invalid-boz

Makefile_OSX

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ endif
730730
#########################################################
731731
CC = gcc
732732
C++ = g++
733-
CFLAGS = -g -O2 -Wall -std=c99 -pedantic -DHAVE_REALPATH $(HDF5CFLAGS)
733+
CFLAGS = -g -O2 -Wall -std=c99 -pedantic -DHAVE_REALPATH -DHAVE_UNISTD_H $(HDF5CFLAGS)
734734
LDFLAGS =
735735
F90C = gfortran
736736
#F90FLAGS = -g -fno-range-check -fallow-invalid-boz

examples/cbf2nexus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@
239239
#include <ctype.h>
240240
#include <time.h>
241241
#include <errno.h>
242+
#ifdef HAVE_UNISTD_H
242243
#include <unistd.h>
244+
#endif
243245
#include <stdint.h>
244246

245247
#include "cbf.h"

examples/cif2c.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@
303303
#include <time.h>
304304
#include <errno.h>
305305
#include "cbf_getopt.h"
306-
#include <unistd.h>
306+
#ifdef HAVE_UNISTD_H
307+
# include <unistd.h>
308+
#endif
307309

308310
#define C2CBUFSIZ 8192
309311

examples/cif2cbf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@
498498
#include <time.h>
499499
#include <errno.h>
500500
#include "cbf_getopt.h"
501+
#ifdef HAVE_UNISTD_H
501502
#include <unistd.h>
503+
#endif
502504

503505
#define C2CBUFSIZ 8192
504506
#define NUMDICTS 50

examples/convert_image.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@
305305
#include <math.h>
306306
#include <errno.h>
307307
#include "cbf_getopt.h"
308-
#include <unistd.h>
308+
#ifdef HAVE_UNISTD_H
309+
# include <unistd.h>
310+
#endif
309311

310312

311313

0 commit comments

Comments
 (0)