Commit 9d44ad9f authored by L. E. Segovia's avatar L. E. Segovia

Fix Windows detection under MinGW

This enables Windows-only primitives only if MSVC is detected.
Otherwise, this lets MinGW take precedence.
parent 6b0fc581
......@@ -40,13 +40,13 @@
namespace SeExpr2 {
// Get debugging flag from environment
bool Expression::debugging = getenv("SE_EXPR_DEBUG") != 0;
bool Expression::debugging = getenv("SE_EXPR_DEBUG") != nullptr;
// Choose the defeault strategy based on what we've compiled with (SEEXPR_ENABLE_LLVM)
// And the environment variables SE_EXPR_DEBUG
static Expression::EvaluationStrategy chooseDefaultEvaluationStrategy() {
if (Expression::debugging) {
std::cerr << "SeExpr2 Debug Mode Enabled " <<
#if defined(WINDOWS)
#if defined(WINDOWS) && defined(_MSC_VER)
_MSC_FULL_VER
#else
__VERSION__
......@@ -69,14 +69,16 @@ Expression::EvaluationStrategy Expression::defaultEvaluationStrategy = chooseDef
class TypePrintExaminer : public SeExpr2::Examiner<true> {
public:
virtual bool examine(const SeExpr2::ExprNode* examinee);
virtual void reset() {};
virtual void reset() {}
virtual ~TypePrintExaminer() {}
};
bool TypePrintExaminer::examine(const ExprNode* examinee) {
const ExprNode* curr = examinee;
int depth = 0;
char buf[1024];
while (curr != 0) {
while (curr != nullptr) {
depth++;
curr = curr->parent();
}
......@@ -89,8 +91,8 @@ bool TypePrintExaminer::examine(const ExprNode* examinee) {
Expression::Expression(Expression::EvaluationStrategy evaluationStrategy)
: _wantVec(true), _expression(""), _evaluationStrategy(evaluationStrategy), _context(&Context::global()),
_desiredReturnType(ExprType().FP(3).Varying()), _parseTree(0), _isValid(0), _parsed(0), _prepped(0),
_interpreter(0), _llvmEvaluator(new LLVMEvaluator()) {
_desiredReturnType(ExprType().FP(3).Varying()), _parseTree(nullptr), _isValid(false), _parsed(false), _prepped(false),
_interpreter(nullptr), _llvmEvaluator(new LLVMEvaluator()) {
ExprFunc::init();
}
......@@ -99,7 +101,7 @@ Expression::Expression(const std::string& e,
EvaluationStrategy evaluationStrategy,
const Context& context)
: _wantVec(true), _expression(e), _evaluationStrategy(evaluationStrategy), _context(&context),
_desiredReturnType(type), _parseTree(0), _isValid(0), _parsed(0), _prepped(0), _interpreter(0),
_desiredReturnType(type), _parseTree(nullptr), _isValid(false), _parsed(false), _prepped(false), _interpreter(nullptr),
_llvmEvaluator(new LLVMEvaluator()) {
ExprFunc::init();
}
......@@ -133,10 +135,10 @@ void Expression::reset() {
delete _llvmEvaluator;
_llvmEvaluator = new LLVMEvaluator();
delete _parseTree;
_parseTree = 0;
_parseTree = nullptr;
if (_evaluationStrategy == UseInterpreter) {
delete _interpreter;
_interpreter = 0;
_interpreter = nullptr;
}
_isValid = 0;
_parsed = 0;
......@@ -346,7 +348,7 @@ const char* Expression::evalStr(VarBlock* varBlock) const {
return _llvmEvaluator->evalStr(varBlock);
}
}
return 0;
return nullptr;
}
} // end namespace SeExpr2/
......@@ -21,8 +21,7 @@
#include "Platform.h"
#if defined(WINDOWS)
#if defined(WINDOWS) && defined(_MSC_VER)
#define _CRT_NONSTDC_NO_DEPRECATE 1
#define _CRT_SECURE_NO_DEPRECATE 1
#define NOMINMAX 1
......@@ -30,7 +29,7 @@
// windows - defined for both Win32 and Win64
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#include <Windows.h>
#include <windows.h>
namespace SeExpr2 {
......
......@@ -28,15 +28,18 @@
#endif
// platform-specific includes
#if defined(_WIN32) || defined(_WINDOWS) || defined(_MSC_VER)
#if defined(_WIN32) || defined(_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
#ifndef WINDOWS
#define WINDOWS
#endif
#ifdef _MSC_VER
#define _CRT_NONSTDC_NO_DEPRECATE 1
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#if !defined(NOMINMAX)
#define NOMINMAX 1
#endif
#endif
// note: because there are some conflicts preventing the use of
// windows.h and COFF.h (one of LLVM include files) in the same
......@@ -44,6 +47,8 @@
// do NOT include windows.h here. The Windows implementation is
// done on the Platform.cpp file, using opaque types.
#if defined(WINDOWS) && defined(_MSC_VER)
#include <malloc.h>
#include <io.h>
#include <tchar.h>
......@@ -51,9 +56,15 @@
#else
// linux/unix/posix
// linux/unix/posix/mingw
#include <stdlib.h>
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <malloc.h>
// Fix generated ExprParser not finding alloca - amyspark
#include <unistd.h>
#else
#include <alloca.h>
#endif
#include <string.h>
#include <pthread.h>
#include <inttypes.h>
......@@ -71,7 +82,7 @@
#include <assert.h>
// missing functions on Windows
#ifdef WINDOWS
#if defined(WINDOWS) && defined(_MSC_VER)
#define snprintf sprintf_s
#define strtok_r strtok_s
typedef __int64 FilePos;
......@@ -94,7 +105,7 @@ typedef off_t FilePos;
#endif
namespace SeExpr2 {
#ifndef WINDOWS
#if !(defined(WINDOWS) && defined(_MSC_VER))
class Timer {
#ifdef __APPLE__
......@@ -166,7 +177,7 @@ namespace SeExprInternal2 {
* Mutex/SpinLock classes
*/
#ifdef WINDOWS
#if defined(WINDOWS) && defined(_MSC_VER)
class _Mutex {
public:
......
......@@ -23,7 +23,7 @@
#include "Platform.h"
// To fix differences in template TYPENAME resolution between MSVC and other compilers
#if defined(WINDOWS)
#if defined(WINDOWS) && defined(_MSC_VER)
# define TYPENAME
#else
# define TYPENAME typename
......@@ -49,7 +49,7 @@ struct my_enable_if {
//! Enable_if failure case (substitution failure is not an error)
template <class T>
struct my_enable_if<false, T> {
#if defined(WINDOWS)
#if defined(WINDOWS) && defined(_MSC_VER)
typedef void TYPE;
#endif
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment