MinGW fixes and warnings

This commit is contained in:
Thomas Krijnen
2016-06-05 14:03:03 +02:00
parent 009870135f
commit 815ed07192
3 changed files with 39 additions and 25 deletions
+6 -1
View File
@@ -316,7 +316,12 @@ IF(MSVC)
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
ElSE() ElSE()
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor) IF(WIN32)
# -fPIC is not relevant on Windows and create pointless warnings
ADD_DEFINITIONS(-Wno-non-virtual-dtor)
ELSE()
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor)
ENDIF()
ENDIF() ENDIF()
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
+4 -1
View File
@@ -27,9 +27,12 @@
#include <iostream> #include <iostream>
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#if defined(_WIN32) && defined(__CYGWIN__) // NB: Streams are only re-opened as binary when compiled with MSVC currently.
// It is unclear what the correct behaviour would be compiled with e.g MinGW
#if defined(_MSC_VER)
#define SET_BINARY_STREAMS #define SET_BINARY_STREAMS
#endif #endif
#ifdef SET_BINARY_STREAMS #ifdef SET_BINARY_STREAMS
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
+29 -23
View File
@@ -47,48 +47,54 @@ using namespace IfcParse;
// strtod_l() is used and a reference to the "C" locale is obtained here. The alternative is // strtod_l() is used and a reference to the "C" locale is obtained here. The alternative is
// to use std::istringstream::imbue(std::locale::classic()), but there are subtleties in // to use std::istringstream::imbue(std::locale::classic()), but there are subtleties in
// parsing in MSVC2010 and it appears to be much slower. // parsing in MSVC2010 and it appears to be much slower.
#ifdef _MSC_VER #if defined(_MSC_VER)
static _locale_t locale = (_locale_t) 0; static _locale_t locale = (_locale_t) 0;
void init_locale() { void init_locale() {
if (locale == (_locale_t) 0) { if (locale == (_locale_t) 0) {
locale = _create_locale(LC_NUMERIC, "C"); locale = _create_locale(LC_NUMERIC, "C");
} }
} }
//#else
#endif
#ifdef __APPLE__ #else
#include <xlocale.h>
//#endif
static locale_t locale = (locale_t) 0;
void init_locale() {
if (locale == (locale_t) 0) {
locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
}
}
#endif
#ifdef __MINGW64__ #if defined(__MINGW64__) || defined(__MINGW32__)
#include <locale> #include <locale>
#include <sstream> #include <sstream>
typedef void* locale_t; typedef void* locale_t;
static locale_t locale = (locale_t) 0; static locale_t locale = (locale_t)0;
void init_locale() {} void init_locale() {}
double strtod_l(const char* start, char** end, locale_t loc) { double strtod_l(const char* start, char** end, locale_t loc) {
double d; double d;
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale::classic()); ss.imbue(std::locale::classic());
ss << start; ss << start;
ss >> d; ss >> d;
size_t nread = ss.tellg(); size_t nread = ss.tellg();
*end = const_cast<char*>(start) + nread; *end = const_cast<char*>(start) + nread;
return d; return d;
} }
#else
#ifdef __APPLE__
#include <xlocale.h>
#endif
#include <locale.h>
static locale_t locale = (locale_t)0;
void init_locale() {
if (locale == (locale_t)0) {
locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
}
}
#endif #endif
#endif
// //
// Opens the file, gets the filesize and reads a chunk in memory // Opens the file, gets the filesize and reads a chunk in memory