Skip to content

Commit ba1c582

Browse files
authored
Define WINBOOL on non-MinGW platforms (#52)
The Windows SDK declares BOOL as an int. Objective C defines BOOl as a char. Those two types clash. MinGW's implementation of the Windows SDK uses the WINBOOL type to avoid this clash. When compiling natively on Windows, we need to manually define WINBOOL. MinGW will define _DEF_WINBOOL_ if it has defined WINBOOL so we can use the same trick here. See https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/ntdef.h#L355
1 parent 6e05e1e commit ba1c582

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Source/win32/WIN32Server.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363

6464
#include <math.h>
6565

66+
// The Windows SDK declares BOOL as an int. Objective C defines BOOl as a char.
67+
// Those two types clash. MinGW's implementation of the Windows SDK uses the WINBOOL
68+
// type to avoid this clash. When compiling natively on Windows, we need to manually
69+
// define WINBOOL.
70+
// MinGW will define _DEF_WINBOOL_ if it has defined WINBOOL so we can use the same trick
71+
// here.
72+
// See https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/ntdef.h#L355
73+
#ifndef _DEF_WINBOOL_
74+
#define _DEF_WINBOOL_
75+
typedef int WINBOOL;
76+
#endif
77+
6678
// To update the cursor..
6779
static BOOL update_cursor = NO;
6880
static BOOL should_handle_cursor = NO;

Source/win32/w32_windowdisplay.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
#include "win32/WIN32Server.h"
3434
#include "win32/WIN32Geometry.h"
3535

36+
// The Windows SDK declares BOOL as an int. Objective C defines BOOl as a char.
37+
// Those two types clash. MinGW's implementation of the Windows SDK uses the WINBOOL
38+
// type to avoid this clash. When compiling natively on Windows, we need to manually
39+
// define WINBOOL.
40+
// MinGW will define _DEF_WINBOOL_ if it has defined WINBOOL so we can use the same trick
41+
// here.
42+
// See https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/ntdef.h#L355
43+
#ifndef _DEF_WINBOOL_
44+
#define _DEF_WINBOOL_
45+
typedef int WINBOOL;
46+
#endif
47+
3648
static void
3749
invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
3850
{

Tools/win32pbs.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@
4040
#include <sys/file.h>
4141
#endif
4242

43+
// The Windows SDK declares BOOL as an int. Objective C defines BOOl as a char.
44+
// Those two types clash. MinGW's implementation of the Windows SDK uses the WINBOOL
45+
// type to avoid this clash. When compiling natively on Windows, we need to manually
46+
// define WINBOOL.
47+
// MinGW will define _DEF_WINBOOL_ if it has defined WINBOOL so we can use the same trick
48+
// here.
49+
// See https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/ntdef.h#L355
50+
#ifndef _DEF_WINBOOL_
51+
#define _DEF_WINBOOL_
52+
typedef int WINBOOL;
53+
#endif
54+
4355
@interface Win32PbOwner : NSObject
4456
{
4557
NSPasteboard *_pb;

0 commit comments

Comments
 (0)