Skip to content

Commit 7b75ce4

Browse files
committed
Guard inclusion of unistd.h
Only include unistd.h where needed.
1 parent ae7b8ab commit 7b75ce4

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
@@ -736,9 +736,9 @@ endif
736736
CC = gcc
737737
C++ = g++
738738
ifneq ($(CBFDEBUG),)
739-
CFLAGS = -g -O0 -Wall -DHAVE_REALPATH -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DCBFDEBUG=1 $(HDF5CFLAGS)
739+
CFLAGS = -g -O0 -Wall -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DHAVE_REALPATH -DCBFDEBUG=1 -DHAVE_UNISTD_H $(HDF5CFLAGS)
740740
else
741-
CFLAGS = -g -O3 -Wall -DHAVE_REALPATH -D_USE_XOPEN_EXTENDED -fno-strict-aliasing $(HDF5CFLAGS)
741+
CFLAGS = -g -O3 -Wall -D_USE_XOPEN_EXTENDED -fno-strict-aliasing -DHAVE_REALPATH -DHAVE_UNISTD_H $(HDF5CFLAGS)
742742
endif
743743
LDFLAGS =
744744
F90C = gfortran

Makefile_LINUX

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

Makefile_MINGW

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ endif
737737
#########################################################
738738
CC = gcc
739739
C++ = g++
740-
CFLAGS = -g -O2 -Wall -I/usr/include -fno-strict-aliasing $(HDF5CFLAGS)
740+
CFLAGS = -g -O2 -Wall -I/usr/include -fno-strict-aliasing -DHAVE_UNISTD_H $(HDF5CFLAGS)
741741
LDFLAGS =
742742
F90C = g95
743743
F90FLAGS = -g

Makefile_MSYS2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ endif
736736
CC = gcc
737737
C++ = g++
738738
CFLAGS = -g -O2 -Wall -D_USE_XOPEN_EXTENDED -DH5_HAVE_WIN32_API \
739-
-DH5_HAVE_MINGW -DH5_USE_110_API -fno-strict-aliasing $(HDF5CFLAGS)
739+
-DH5_HAVE_MINGW -DH5_USE_110_API -fno-strict-aliasing -DHAVE_UNISTD_H \
740+
$(HDF5CFLAGS)
740741
LDFLAGS =
741742
F90C = gfortran
742743
#F90FLAGS = -g -fno-range-check -fallow-invalid-boz

Makefile_OSX

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ endif
736736
#########################################################
737737
CC = gcc
738738
C++ = g++
739-
CFLAGS = -g -O2 -Wall -std=c99 -pedantic -DHAVE_REALPATH $(HDF5CFLAGS)
739+
CFLAGS = -g -O2 -Wall -std=c99 -pedantic -DHAVE_REALPATH -DHAVE_UNISTD_H $(HDF5CFLAGS)
740740
LDFLAGS =
741741
F90C = gfortran
742742
#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)