Skip to content

Commit

Permalink
Add support for compilation on Windows using mingw32.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulchenko committed Jul 10, 2015
1 parent 531de99 commit 6f9eaf9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ SET(CMAKE_MODULE_PATH
"${CMAKE_MODULE_PATH}")

IF (NOT MSVC)
IF (MINGW)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format")
ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration -Werror=format")
ENDIF(MINGW)
ENDIF(NOT MSVC)


# Flags
# When using MSVC
IF(MSVC)
Expand Down
4 changes: 2 additions & 2 deletions Timer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "general.h"

#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))
#include <time.h>
#else
#include <sys/time.h>
Expand All @@ -19,7 +19,7 @@ typedef struct _Timer
double startusertime;
double startsystime;

#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))
time_t base_time;
#endif

Expand Down
2 changes: 1 addition & 1 deletion general.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "luaT.h"
#include "TH.h"

#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))

#define snprintf _snprintf
#define popen _popen
Expand Down
2 changes: 1 addition & 1 deletion lib/TH/THGeneral.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void THFree(void *ptr)

double THLog1p(const double x)
{
#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))
volatile double y = 1 + x;
return log(y) - ((y-1)-x)/y ; /* cancels errors with IEEE arithmetic */
#else
Expand Down
2 changes: 1 addition & 1 deletion lib/TH/THGeneral.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ do { \
#define THMin(X, Y) ((X) < (Y) ? (X) : (Y))
#define THMax(X, Y) ((X) > (Y) ? (X) : (Y))

#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))
# define log1p(x) THLog1p(x)
#define snprintf _snprintf
#define popen _popen
Expand Down
4 changes: 2 additions & 2 deletions lib/luaT/luaT.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern "C" {
# endif
#endif

#ifdef _MSC_VER
#if (defined(_MSC_VER) || defined(__MINGW32__))
# define DLL_EXPORT __declspec(dllexport)
# define DLL_IMPORT __declspec(dllimport)
# ifdef luaT_EXPORTS
Expand Down Expand Up @@ -108,7 +108,7 @@ LUAT_API int luaT_lua_pushudata(lua_State *L);
/* comments show what function (that you should use) they call now */
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define LUAT_DEPRECATED __attribute__((__deprecated__))
#elif defined(_MSC_VER)
#elif (defined(_MSC_VER) || defined(__MINGW32__))
#define LUAT_DEPRECATED __declspec(deprecated)
#else
#define LUAT_DEPRECATED
Expand Down

0 comments on commit 6f9eaf9

Please sign in to comment.