Fixed some preprocessor directives for MinGW

The purpose of these changes is to make the distinction between
compiling under Windows (in which case _WIN32 is defined) and
compiling with the Microsoft compiler (in which case _MSC_VER is
defined). These changes are from the patch submitted by David
Fronczek.
This commit is contained in:
Ray Speth 2012-01-19 20:30:26 +00:00
parent 6798f18c4e
commit d3c09984d0
19 changed files with 34 additions and 51 deletions

View file

@ -6,7 +6,7 @@
#include "kernel/ct_defs.h"
#ifdef WIN32
#ifdef _WIN32
// Either build as a DLL under Windows or not.
// the decision relies upon whether the NO_DLL_BUILD define is
// set or not.
@ -17,7 +17,6 @@
#define DLL_IMPORT __declspec(dllimport)
#define DLL_EXPORT __declspec(dllexport)
#endif
#else
// On other platforms, we turn off the DLL macros.
#define DLL_EXPORT

View file

@ -28,7 +28,7 @@
using namespace std;
using namespace Cantera;
#ifdef WIN32
#ifdef _WIN32
#include "windows.h"
#endif
@ -97,7 +97,7 @@ namespace Cantera {
*/
extern "C" {
#ifdef WIN32
#ifdef _WIN32
#ifndef NO_DLL_BUILD
/*
* The microsoft docs says we may need this in some

View file

@ -74,13 +74,6 @@ int openRankine(int np, void* p) {
double efficiency = work/heat_in;
cout << "efficiency = " << efficiency << endl;
#ifdef WIN32
#ifndef CXX_DEMO
cout << "press any key to end" << endl;
char ch;
cin >> ch;
#endif
#endif
return 0;
}

View file

@ -8,11 +8,6 @@
#ifndef CANTERA_H_INCL
#define CANTERA_H_INCL
// definitions
#ifndef CANTERA_APP
#define CANTERA_APP
#endif
namespace Cantera_CXX{ }
using namespace Cantera_CXX;

View file

@ -2,7 +2,7 @@
#define FCTC_DEFS_H
// Build as a DLL under Windows
#ifdef WIN32
#ifdef _WIN32
#define DLL_IMPORT __declspec(dllimport)
#define DLL_EXPORT __declspec(dllexport)
#else

View file

@ -27,7 +27,7 @@
#include <sunmath.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#include <float.h>
#endif
@ -39,7 +39,7 @@ namespace mdp {
/*
* @param tmp number to be checked
*/
#ifdef WIN32
#ifdef _WIN32
void checkFinite(const double tmp) {
if (_finite(tmp)) {
if(_isnan(tmp)) {
@ -108,7 +108,7 @@ namespace mdp {
*
* @param tmp number to be checked
*/
#ifdef WIN32
#ifdef _WIN32
void checkZeroFinite(const double tmp) {
if ((tmp == 0.0) || (! _finite(tmp))) {
if (tmp == 0.0) {

View file

@ -86,10 +86,6 @@ 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

View file

@ -19,7 +19,7 @@
// These defines are needed for the windows Sleep() function
// - comment them out if you don't want the Sleep function.
//#ifdef WIN32
//#ifdef _WIN32
//#include "Windows.h"
//#include "Winbase.h"
//#endif
@ -114,7 +114,7 @@ namespace ctml {
<< "write()\n";
f.close();
string logfile = tmpDir()+"/ct2ctml.log";
#ifdef WIN32
#ifdef _WIN32
string cmd = pypath() + " " + "\"" + path + "\"" + "> " + logfile + " 2>&1";
#else
string cmd = "sleep " + sleep() + "; " + "\"" + pypath() + "\"" +
@ -156,7 +156,7 @@ namespace ctml {
* It probably has to do with NFS syncing problems.
* 3/3/06
*/
#ifndef WIN32
#ifndef _WIN32
string sss = sleep();
if (debug > 0) {
writelog("sleeping for " + sss + " secs+\n");
@ -209,7 +209,7 @@ namespace ctml {
// if the conversion succeeded and DEBUG_PATHS is not defined,
// then clean up by deleting the temporary Python file.
#ifndef DEBUG_PATHS
//#ifdef WIN32
//#ifdef _WIN32
//cmd = "cmd /C rm " + path;
if (debug == 0)
remove(path.c_str());

View file

@ -26,11 +26,14 @@
#include <fstream>
#include <memory>
#ifdef WIN32
#ifdef _WIN32
#include <algorithm>
#include <functional>
#include <new>
#include <windows.h>
#endif
#ifdef _MSC_VER
#pragma comment(lib, "advapi32")
#endif
@ -757,7 +760,7 @@ namespace Cantera {
* @param msg c++ string to be written to the screen
* @ingroup textlogs
*/
#ifdef WIN32
#ifdef _WIN32
long int readStringRegistryKey(const std::string& keyName, const std::string& valueName,
std::string& value, const std::string& defaultValue);
#endif
@ -1027,7 +1030,7 @@ protected:
// file is not found. But I (dgg) don't think it makes much sense,
// so it is replaced by:
path = findInputFile(file);
#ifdef WIN32
#ifdef _WIN32
// RFB: For Windows make the path POSIX compliant so code looking for directory
// separators is simpler. Just look for '/' not both '/' and '\\'
replace_if( path.begin(), path.end(), bind2nd( equal_to<char>(), '\\'), '/' ) ;
@ -1145,7 +1148,7 @@ protected:
}
}
#ifdef WIN32
#ifdef _WIN32
long int Application::readStringRegistryKey(const std::string& keyName, const std::string& valueName,
std::string& value, const std::string& defaultValue) {
@ -1359,7 +1362,7 @@ protected:
dirs.push_back(".");
#ifdef WIN32
#ifdef _WIN32
// Under Windows, the Cantera setup utility records the installation
// directory in the registry. Data files are stored in the 'data' and
// 'templates' subdirectories of the main installation directory.
@ -1618,7 +1621,7 @@ protected:
va_start( args, fmt ) ;
#if defined(WIN32) && defined(MSC_VER)
#ifdef _MSC_VER
_vsnprintf( sbuf, BUFSIZE, fmt, args ) ;
#else
vsprintf( sbuf, fmt, args ) ;

View file

@ -8,7 +8,7 @@
//@{
#include "ct_defs.h"
#ifdef WIN32
#ifdef _MSC_VER
#define SNPRINTF _snprintf
#else
#define SNPRINTF snprintf

View file

@ -549,14 +549,11 @@ elif env['F90'] == 'ifort':
env['FORTRANMODDIR'] = '${TARGET.dir}'
if env['CC'] == 'cl':
env['WIN32'] = True
# embed manifest file
env['LINKCOM'] = [env['LINKCOM'],
'if exist ${TARGET}.manifest mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1']
env['SHLINKCOM'] = [env['SHLINKCOM'],
'if exist ${TARGET}.manifest mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2']
else:
env['WIN32'] = False
if env['boost_inc_dir']:
env.Append(CPPPATH=env['boost_inc_dir'])
@ -739,7 +736,6 @@ 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

View file

@ -16,10 +16,7 @@ extern "C" {
#ifndef _cvode_h
#define _cvode_h
#ifdef WIN32
#include <stdlib.h>
#endif
#include <stdio.h>
#include "llnltyps.h"
#include "nvector.h"

View file

@ -1,6 +1,6 @@
#include "time.h"
#ifdef MSDOS
#if defined(MSDOS) || defined (__MINGW32__)
#undef USE_CLOCK
#define USE_CLOCK
#endif

View file

@ -1,6 +1,6 @@
#include "time.h"
#ifdef MSDOS
#if defined(MSDOS) || defined (__MINGW32__)
#undef USE_CLOCK
#define USE_CLOCK
#endif

View file

@ -108,12 +108,14 @@ extern void f_init(void);
extern int (*f__donewrec)(void), t_putc(int), x_wSL(void);
extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*);
extern int c_sfe(cilist*), z_rnew(void);
#ifndef _WIN32
extern int isatty(int);
#endif
#ifdef _MSC_VER
#define ISATTY _isatty
#define FILENO _fileno
#define ACCESS _access
#else
extern int isatty(int);
#define ISATTY isatty
#define FILENO fileno
#define ACCESS access

View file

@ -75,7 +75,7 @@ un_getc(int x, FILE *f__cf)
#ifdef KR_headers
extern int ungetc();
#else
#ifndef _MSC_VER
#ifndef _WIN32
extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */
#endif
#endif

View file

@ -66,7 +66,7 @@ un_getc(int x, FILE *f__cf)
{ return ungetc(x,f__cf); }
#else
#define un_getc ungetc
#ifndef _MSC_VER
#ifndef _WIN32
extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */
#endif
#endif

View file

@ -19,12 +19,14 @@ extern "C" {
#ifdef __cplusplus
extern "C" {
#endif
extern int getpid(void);
extern int getpid(void);
#ifndef _WIN32
extern int isatty(int);
#endif
#ifdef _MSC_VER
#define ISATTY _isatty
#define FILENO _fileno
#else
extern int isatty(int);
#define ISATTY isatty
#define FILENO fileno
#endif

View file

@ -1526,13 +1526,13 @@ void strip_item_from_token(int iword, TOKEN *tok)
{
if (!tok) return;
if (iword < 0 || iword > tok->ntokes) return;
#ifdef WIN32
#ifdef _MSC_VER
__w64 int ioffset = tok->tok_ptr[iword] - tok->tok_str;
#else
size_t ioffset = tok->tok_ptr[iword] - tok->tok_str;
#endif
size_t ilength = strlen(tok->tok_ptr[iword]);
#ifdef WIN32
#ifdef _MSC_VER
__w64 int i = ioffset;
__w64 int j = ioffset + ilength;
#else