Skip to content

Commit

Permalink
Define WINBOOL on non-MinGW platforms (#52)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
qmfrederik committed Sep 17, 2024
1 parent 6e05e1e commit ba1c582
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/win32/WIN32Server.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@

#include <math.h>

// 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
#ifndef _DEF_WINBOOL_
#define _DEF_WINBOOL_
typedef int WINBOOL;
#endif

// To update the cursor..
static BOOL update_cursor = NO;
static BOOL should_handle_cursor = NO;
Expand Down
12 changes: 12 additions & 0 deletions Source/win32/w32_windowdisplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
#include "win32/WIN32Server.h"
#include "win32/WIN32Geometry.h"

// 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
#ifndef _DEF_WINBOOL_
#define _DEF_WINBOOL_
typedef int WINBOOL;
#endif

static void
invalidateWindow(WIN32Server *svr, HWND hwnd, RECT rect)
{
Expand Down
12 changes: 12 additions & 0 deletions Tools/win32pbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
#include <sys/file.h>
#endif

// 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
#ifndef _DEF_WINBOOL_
#define _DEF_WINBOOL_
typedef int WINBOOL;
#endif

@interface Win32PbOwner : NSObject
{
NSPasteboard *_pb;
Expand Down

0 comments on commit ba1c582

Please sign in to comment.