Skip to content

Commit c669219

Browse files
committed
Merge pull request #287 from pkulchenko/torch-compile-mingw32
Add support for compilation on Windows using mingw32
2 parents 531de99 + 6f9eaf9 commit c669219

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ SET(CMAKE_MODULE_PATH
1111
"${CMAKE_MODULE_PATH}")
1212

1313
IF (NOT MSVC)
14+
IF (MINGW)
15+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format")
16+
ELSE()
1417
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=format")
18+
ENDIF(MINGW)
1519
ENDIF(NOT MSVC)
1620

17-
1821
# Flags
1922
# When using MSVC
2023
IF(MSVC)

Timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "general.h"
22

3-
#ifdef _MSC_VER
3+
#if (defined(_MSC_VER) || defined(__MINGW32__))
44
#include <time.h>
55
#else
66
#include <sys/time.h>
@@ -19,7 +19,7 @@ typedef struct _Timer
1919
double startusertime;
2020
double startsystime;
2121

22-
#ifdef _MSC_VER
22+
#if (defined(_MSC_VER) || defined(__MINGW32__))
2323
time_t base_time;
2424
#endif
2525

general.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "luaT.h"
88
#include "TH.h"
99

10-
#ifdef _MSC_VER
10+
#if (defined(_MSC_VER) || defined(__MINGW32__))
1111

1212
#define snprintf _snprintf
1313
#define popen _popen

lib/TH/THGeneral.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void THFree(void *ptr)
150150

151151
double THLog1p(const double x)
152152
{
153-
#ifdef _MSC_VER
153+
#if (defined(_MSC_VER) || defined(__MINGW32__))
154154
volatile double y = 1 + x;
155155
return log(y) - ((y-1)-x)/y ; /* cancels errors with IEEE arithmetic */
156156
#else

lib/TH/THGeneral.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ do { \
8989
#define THMin(X, Y) ((X) < (Y) ? (X) : (Y))
9090
#define THMax(X, Y) ((X) > (Y) ? (X) : (Y))
9191

92-
#ifdef _MSC_VER
92+
#if (defined(_MSC_VER) || defined(__MINGW32__))
9393
# define log1p(x) THLog1p(x)
9494
#define snprintf _snprintf
9595
#define popen _popen

lib/luaT/luaT.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" {
1818
# endif
1919
#endif
2020

21-
#ifdef _MSC_VER
21+
#if (defined(_MSC_VER) || defined(__MINGW32__))
2222
# define DLL_EXPORT __declspec(dllexport)
2323
# define DLL_IMPORT __declspec(dllimport)
2424
# ifdef luaT_EXPORTS
@@ -108,7 +108,7 @@ LUAT_API int luaT_lua_pushudata(lua_State *L);
108108
/* comments show what function (that you should use) they call now */
109109
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
110110
#define LUAT_DEPRECATED __attribute__((__deprecated__))
111-
#elif defined(_MSC_VER)
111+
#elif (defined(_MSC_VER) || defined(__MINGW32__))
112112
#define LUAT_DEPRECATED __declspec(deprecated)
113113
#else
114114
#define LUAT_DEPRECATED

0 commit comments

Comments
 (0)