Skip to content

Commit 71bd7b2

Browse files
davywmpictor
authored andcommitted
Made non MSVC include files conditional.
* Made unistd.h include conditional by cmake HAVE_UNISTD_H flag. * Made dirent.h include conditional by cmake HAVE_DIRENT_H flag. * Made sys/params.h include conditional by cmake HAVE_SYS_PARAMS_H flag. * Made stdbool.h include conditinal by cmake HAVE_STDBOOL_H flag. * Added scl_stdbool.h as an alternative for stdbool.h. * Added xgetopt.cc/xgetopt.h to be included when HAVE_GETOPT flag false.
1 parent 48dff49 commit 71bd7b2

File tree

17 files changed

+377
-17
lines changed

17 files changed

+377
-17
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,16 @@ INCLUDE(${SCL_CMAKE_DIR}/FindYACC.cmake)
204204
CHECK_INCLUDE_FILE(ndir.h HAVE_NDIR_H)
205205
CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H)
206206
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
207+
CHECK_INCLUDE_FILE(sys/params.h HAVE_SYS_PARAMS_H)
207208
CHECK_INCLUDE_FILE(sysent.h HAVE_SYSENT_H)
208209
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
210+
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
211+
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
209212

210213
CHECK_FUNCTION_EXISTS(abs HAVE_ABS)
211214
CHECK_FUNCTION_EXISTS(memcpy HAVE_MEMCPY)
212215
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
216+
CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
213217

214218
CHECK_TYPE_SIZE("ssize_t" SSIZE_T)
215219

include/express/basic.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,18 @@
7272
*
7373
*/
7474

75+
#include <scl_cf.h>
7576
#include <stdio.h>
7677

7778
/******************************/
7879
/* type Boolean and constants */
7980
/******************************/
8081

81-
#include <stdbool.h>
82-
82+
#ifdef HAVE_STDBOOL_H
83+
# include <stdbool.h>
84+
#else
85+
# include <scl_stdbool.h>
86+
#endif
8387

8488
/************************/
8589
/* Generic pointer type */

include/scl_cf_cmake.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
#ifndef SCL_CF_H
2+
#define SCL_CF_H
3+
14
/**** Define statements for CMake ****/
25
#cmakedefine HAVE_NDIR_H 1
36
#cmakedefine HAVE_STDARG_H 1
47
#cmakedefine HAVE_SYS_STAT_H 1
58
#cmakedefine HAVE_SYSENT_H 1
69
#cmakedefine HAVE_UNISTD_H 1
10+
#cmakedefine HAVE_DIRENT_H 1
11+
#cmakedefine HAVE_STDBOOL_H 1
12+
713
#cmakedefine HAVE_ABS 1
814
#cmakedefine HAVE_MEMCPY 1
915
#cmakedefine HAVE_MEMMOVE 1
16+
#cmakedefine HAVE_GETOPT 1
17+
1018
#cmakedefine HAVE_SSIZE_T 1
1119

20+
#endif /* SCL_CF_H */

include/scl_stdbool.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef STDBOOL_H_
2+
#define STDBOOL_H_
3+
4+
/**
5+
* stdbool.h - ISO C99 Boolean type
6+
* Author - Bill Chatfield
7+
* E-mail - bill underscore chatfield at yahoo dot com
8+
* Copyright - You are free to use for any purpose except illegal acts
9+
* Warrenty - None: don't blame me if it breaks something
10+
*
11+
* In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but
12+
* some compilers don't offer these yet. This header file is an
13+
* implementation of the standard ISO C99 stdbool.h header file. It checks
14+
* for various compiler versions and defines things that are missing in
15+
* those versions.
16+
*
17+
* The GNU and Watcom compilers include a stdbool.h, but the Borland
18+
* C/C++ 5.5.1 compiler and the Microsoft compilers do not.
19+
*
20+
* See http://predef.sourceforge.net/precomp.html for compile macros.
21+
*/
22+
23+
#ifndef __cplusplus
24+
25+
/**
26+
* Borland C++ 5.5.1 does not define _Bool.
27+
*/
28+
#ifdef __BORLANDC__
29+
typedef int _Bool;
30+
#endif
31+
32+
/**
33+
* Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005,
34+
* and version 15.00.30729.01, which comes with Visual C++ 2008, do not
35+
* define _Bool.
36+
*/
37+
#if defined(_MSC_VER)
38+
typedef int _Bool;
39+
#endif
40+
41+
/**
42+
* Define the Boolean macros only if they are not already defined.
43+
*/
44+
#ifndef __bool_true_false_are_defined
45+
#define bool _Bool
46+
#define Boolean _Bool
47+
#define false 0
48+
#define true 1
49+
#define __bool_true_false_are_defined 1
50+
#endif
51+
52+
#endif /* __cplusplus */
53+
54+
#endif /*STDBOOL_H_*/

src/clutils/dirobj.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4040
*/
4141

42+
#include <scl_cf.h>
4243
#include <dirobj.h>
43-
#include <dirent.h>
44-
45-
# include <scl_cf.h>
44+
#ifdef HAVE_DIRENT_H
45+
# include <dirent.h>
46+
#endif
4647

4748
/* for stat() file status */
4849
#ifdef HAVE_SYS_STAT_H

src/clutils/dirobj.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
//
3434
///////////////////////////////////////////////////////////////////////////////
3535

36+
#include <scl_cf.h>
3637
#include <stdlib.h>
3738

3839
#include <string.h>
39-
#include <sys/param.h>
40+
#ifdef HAVE_SYS_PARAMS_H
41+
# include <sys/param.h>
42+
#endif
4043

4144
#include <string>
4245

src/exppp/exppp.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
#include <scl_cf.h>
12
#include <stdlib.h>
23
#include <stdio.h>
34
#include <memory.h>
45
#include <errno.h>
56
#include <sys/stat.h>
6-
#include <unistd.h>
7-
#include <stdbool.h>
7+
#ifdef HAVE_UNISTD_H
8+
# include <unistd.h>
9+
#endif
10+
#ifdef HAVE_STDBOOL_H
11+
# include <stdbool.h>
12+
#else
13+
# include <scl_stdbool.h>
14+
#endif
815

916
#ifdef __STDC__
1017
#include <stdarg.h>

src/express/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ include_directories(
6464

6565
add_definitions( -DFLEX )
6666

67+
if(MSVC)
68+
add_definitions( -DYY_NO_UNISTD_H )
69+
endif(MSVC)
70+
6771
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "")
6872

6973
if(APPLE)

src/express/error.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@
5151
* prettied up interface to print_objects_when_running
5252
*/
5353

54+
#include <scl_cf.h>
5455
#include <stdlib.h>
5556
#include "conf.h"
5657
#include <setjmp.h>
57-
#include <unistd.h>
58+
#ifdef HAVE_UNISTD_H
59+
# include <unistd.h>
60+
#endif
5861

5962
#define ERROR_C
6063
#include "signal.h"

src/express/expr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@
7070
*
7171
*/
7272

73+
#include <scl_cf.h>
7374
#define EXPRESSION_C
74-
#include <unistd.h>
75+
#ifdef HAVE_UNISTD_H
76+
# include <unistd.h>
77+
#endif
7578
#include "express/expr.h"
7679
#include "express/resolve.h"
7780

0 commit comments

Comments
 (0)