Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd651d1

Browse files
committed
Merge pull request micropython#597 from stinos/mingw-compilation
mingw: Fix compilation issues
2 parents c3dcb59 + f45a83d commit bd651d1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

unix/modtime.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,19 @@ void msec_sleep_tv(struct timeval *tv) {
4545
#define sleep_select select
4646
#endif
4747

48-
#if CLOCKS_PER_SEC == 1000000 // POSIX
48+
// mingw32 defines CLOCKS_PER_SEC as ((clock_t)<somevalue>) but preprocessor does not handle casts
49+
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
50+
#define MP_REMOVE_BRACKETSA(x)
51+
#define MP_REMOVE_BRACKETSB(x) MP_REMOVE_BRACKETSA x
52+
#define MP_REMOVE_BRACKETSC(x) MP_REMOVE_BRACKETSB x
53+
#define MP_CLOCKS_PER_SEC MP_REMOVE_BRACKETSC(CLOCKS_PER_SEC)
54+
#else
55+
#define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC
56+
#endif
57+
58+
#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX
4959
#define CLOCK_DIV 1000.0
50-
#elif CLOCKS_PER_SEC == 1000 // WIN32
60+
#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32
5161
#define CLOCK_DIV 1.0
5262
#else
5363
#error Unsupported clock() implementation

windows/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <stdlib.h>
2828
#include <stdio.h>
29-
#include <Windows.h>
29+
#include <windows.h>
3030

3131
HANDLE hSleepEvent = NULL;
3232

windows/sleep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include <Windows.h>
27+
#include <windows.h>
2828

2929
extern HANDLE hSleepEvent;
3030

0 commit comments

Comments
 (0)