From 098501cbe48ecfaf8b1d63517f1b63be0c136995 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 14 Dec 2011 19:33:53 +0000 Subject: [PATCH] Fixed several platform-dependent preprocessor defines to work with Windows --- Cantera/src/base/stringUtils.cpp | 4 +++- SConstruct | 11 ++++++++++- config.h.in.scons | 4 ++++ ext/SConscript | 5 +++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cantera/src/base/stringUtils.cpp b/Cantera/src/base/stringUtils.cpp index 54eb66d32..3ab2a477a 100644 --- a/Cantera/src/base/stringUtils.cpp +++ b/Cantera/src/base/stringUtils.cpp @@ -11,6 +11,8 @@ // Copyright 2001 California Institute of Technology //@{ +#include "ct_defs.h" + #ifdef WIN32 #pragma warning(disable:4786) #pragma warning(disable:4503) @@ -20,7 +22,7 @@ #define SNPRINTF snprintf #endif //@} -#include "ct_defs.h" + #include "stringUtils.h" #include "ctexceptions.h" #include "global.h" diff --git a/SConstruct b/SConstruct index 48387202d..e86745cd4 100644 --- a/SConstruct +++ b/SConstruct @@ -439,10 +439,18 @@ elif env['F90'] == 'ifort': env['FORTRANMODDIR'] = '${TARGET.dir}' +if env['CC'] == 'gcc': + env['WIN32'] = False +elif env['CC'] == 'cl': + env['WIN32'] = True +else: + assert False + conf = Configure(env) env['HAS_SSTREAM'] = conf.CheckCXXHeader('sstream', '<>') - +env['HAS_TIMES_H'] = conf.CheckCHeader('sys/times.h', '""') +env['HAS_UNISTD_H'] = conf.CheckCHeader('unistd.h', '""') env = conf.Finish() if env['cantera_python_home'] == '' and env['prefix'] != defaults.prefix: @@ -496,6 +504,7 @@ def cdefine(definevar, configvar, comp=True, value=1): configh[definevar] = None cdefine('DEBUG_MODE', 'debug') +cdefine('WIN32', 'WIN32') # Need to test all of these to see what platform.system() returns configh['SOLARIS'] = 1 if env['OS'] == 'Solaris' else None diff --git a/config.h.in.scons b/config.h.in.scons index 4121295c8..a884fa4cb 100755 --- a/config.h.in.scons +++ b/config.h.in.scons @@ -77,6 +77,10 @@ typedef int ftnlen; // Fortran hidden string length type // microsoft vc++ being used as the compiler %(WINMSVC)s +// Despite the name, this variable is expected to be defined +// on both 32 and 64 bit Windows +%(WIN32)s + // Identify whether the operating system is solaris // with a native compiler %(SOLARIS)s diff --git a/ext/SConscript b/ext/SConscript index 3d9691160..97ef86b9b 100644 --- a/ext/SConscript +++ b/ext/SConscript @@ -9,6 +9,11 @@ libs = [('tpx','tpx',['cpp'])] if env['build_with_f2c']: libs.append(('f2c_math', 'ctmath', ['cpp','c'])) + if not localenv['HAS_TIMES_H']: + localenv.Append(CPPDEFINES=['USE_CLOCK']) + if not localenv['HAS_UNISTD_H']: + localenv.Append(CPPDEFINES=['MSDOS']) + # Create arith.h using the arithchk program if not os.path.exists('arith.h'): arithenv = env.Clone()