Skip to content

Commit 815ed07

Browse files
committed
MinGW fixes and warnings
1 parent 0098701 commit 815ed07

3 files changed

Lines changed: 39 additions & 25 deletions

File tree

cmake/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ IF(MSVC)
316316
ENDIF()
317317
ENDFOREACH()
318318
ElSE()
319-
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor)
319+
IF(WIN32)
320+
# -fPIC is not relevant on Windows and create pointless warnings
321+
ADD_DEFINITIONS(-Wno-non-virtual-dtor)
322+
ELSE()
323+
ADD_DEFINITIONS(-fPIC -Wno-non-virtual-dtor)
324+
ENDIF()
320325
ENDIF()
321326

322327
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}

src/ifcgeomserver/IfcGeomServer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
#include <iostream>
2828
#include <boost/cstdint.hpp>
2929

30-
#if defined(_WIN32) && defined(__CYGWIN__)
30+
// NB: Streams are only re-opened as binary when compiled with MSVC currently.
31+
// It is unclear what the correct behaviour would be compiled with e.g MinGW
32+
#if defined(_MSC_VER)
3133
#define SET_BINARY_STREAMS
3234
#endif
35+
3336
#ifdef SET_BINARY_STREAMS
3437
#include <io.h>
3538
#include <fcntl.h>

src/ifcparse/IfcParse.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,48 +47,54 @@ using namespace IfcParse;
4747
// strtod_l() is used and a reference to the "C" locale is obtained here. The alternative is
4848
// to use std::istringstream::imbue(std::locale::classic()), but there are subtleties in
4949
// parsing in MSVC2010 and it appears to be much slower.
50-
#ifdef _MSC_VER
50+
#if defined(_MSC_VER)
51+
5152
static _locale_t locale = (_locale_t) 0;
5253
void init_locale() {
5354
if (locale == (_locale_t) 0) {
5455
locale = _create_locale(LC_NUMERIC, "C");
5556
}
5657
}
57-
//#else
58-
#endif
5958

60-
#ifdef __APPLE__
61-
#include <xlocale.h>
62-
//#endif
63-
static locale_t locale = (locale_t) 0;
64-
void init_locale() {
65-
if (locale == (locale_t) 0) {
66-
locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
67-
}
68-
}
69-
#endif
59+
#else
7060

71-
#ifdef __MINGW64__
61+
#if defined(__MINGW64__) || defined(__MINGW32__)
7262
#include <locale>
7363
#include <sstream>
7464

7565
typedef void* locale_t;
76-
static locale_t locale = (locale_t) 0;
66+
static locale_t locale = (locale_t)0;
7767

7868
void init_locale() {}
7969

8070
double strtod_l(const char* start, char** end, locale_t loc) {
81-
double d;
82-
std::stringstream ss;
83-
ss.imbue(std::locale::classic());
84-
ss << start;
85-
ss >> d;
86-
size_t nread = ss.tellg();
87-
*end = const_cast<char*>(start) + nread;
88-
return d;
71+
double d;
72+
std::stringstream ss;
73+
ss.imbue(std::locale::classic());
74+
ss << start;
75+
ss >> d;
76+
size_t nread = ss.tellg();
77+
*end = const_cast<char*>(start) + nread;
78+
return d;
8979
}
80+
81+
#else
82+
83+
#ifdef __APPLE__
84+
#include <xlocale.h>
85+
#endif
86+
#include <locale.h>
87+
88+
static locale_t locale = (locale_t)0;
89+
void init_locale() {
90+
if (locale == (locale_t)0) {
91+
locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
92+
}
93+
}
94+
9095
#endif
9196

97+
#endif
9298

9399
//
94100
// Opens the file, gets the filesize and reads a chunk in memory

0 commit comments

Comments
 (0)