Skip to content

Commit

Permalink
Now compiles with the mingw compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
martell committed Jan 24, 2013
1 parent 8141ad8 commit 4de6236
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cocos2dx/platform/win32/CCPlatformDefine.h
@@ -1,6 +1,9 @@
#ifndef __CCPLATFORMDEFINE_H__
#define __CCPLATFORMDEFINE_H__

#ifdef __MINGW32__
#include <string.h>
#endif

#if defined(_USRDLL)
#define CC_DLL __declspec(dllexport)
Expand Down
3 changes: 3 additions & 0 deletions cocos2dx/platform/win32/CCStdC.cpp
Expand Up @@ -24,6 +24,8 @@ THE SOFTWARE.

#include "CCStdC.h"

#ifndef __MINGW32__

int gettimeofday(struct timeval * val, struct timezone *)
{
if (val)
Expand All @@ -37,3 +39,4 @@ int gettimeofday(struct timeval * val, struct timezone *)
return 0;
}

#endif // __MINGW32__
25 changes: 24 additions & 1 deletion cocos2dx/platform/win32/CCStdC.h
Expand Up @@ -29,6 +29,7 @@ THE SOFTWARE.
#include <float.h>

// for math.h on win32 platform
#ifndef __MINGW32__

#if !defined(_USE_MATH_DEFINES)
#define _USE_MATH_DEFINES // make M_PI can be use
Expand All @@ -42,6 +43,8 @@ THE SOFTWARE.
#define snprintf _snprintf
#endif

#endif // __MINGW32__

#include <math.h>
#include <string.h>
#include <stdarg.h>
Expand All @@ -50,11 +53,27 @@ THE SOFTWARE.
#include <time.h>

// for MIN MAX and sys/time.h on win32 platform
#ifndef __MINGW32__

#define MIN min
#define MAX max

#if _MSC_VER >= 1600
#else // __MINGW32__

#include <sys/time.h>

#ifndef MIN
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#endif // MIN

#ifndef MAX
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
#endif // MAX

#endif // __MINGW32__


#if _MSC_VER >= 1600 || defined(__MINGW32__)
#include <stdint.h>
#else
#include "./compat/stdint.h"
Expand All @@ -65,6 +84,8 @@ THE SOFTWARE.
#include <Windows.h>
#include <WinSock2.h>

#ifndef __MINGW32__

struct timezone
{
int tz_minuteswest;
Expand All @@ -73,5 +94,7 @@ struct timezone

int CC_DLL gettimeofday(struct timeval *, struct timezone *);

#endif // __MINGW32__

#endif // __CC_STD_C_H__

7 comments on commit 4de6236

@bakwc
Copy link

@bakwc bakwc commented on 4de6236 Jun 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you really managed to build it under mingw? What build system have you used? I don't see any makefile for win32 mingw.

@martell
Copy link
Contributor Author

@martell martell commented on 4de6236 Jun 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I have built it with mingw64 toolchains. For both i686 and x86_64 architectures.
There is no mingw makefile. I use CMake to build cocos2dx.

@bakwc
Copy link

@bakwc bakwc commented on 4de6236 Jun 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you convert vcxproj to CMakeLists.txt?

@martell
Copy link
Contributor Author

@martell martell commented on 4de6236 Jun 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't, I wrote the CMakeLists from scratch.
From that CMakeLists then a project of any type can be generated

@bakwc
Copy link

@bakwc bakwc commented on 4de6236 Jun 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please share it?

@minggo
Copy link
Contributor

@minggo minggo commented on 4de6236 Jun 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martell
Can CMake generate xcode project?
Is CMake suitable for template?

@martell
Copy link
Contributor Author

@martell martell commented on 4de6236 Jun 7, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bakwc unfortunately I can't, it's being used as part of a bigger project. i.e project specific atm
Hint. https://twitter.com/MartellMalone/status/330079350152122368/photo/1
As in its a custom version of cmake, not the official one

@minggo Yes it can generate many project types including xcode.
No, it can not generate templates, as templates would be IDE specific

I think your python script solution would be just as good so their is no point switching atm

Please sign in to comment.