Skip to content

Commit a49c818

Browse files
kbleesdscho
authored andcommitted
MSVC: fix winansi.c compile errors
Some constants (such as LF_FACESIZE) are undefined with -DNOGDI (set in the Makefile), and CONSOLE_FONT_INFOEX is available in MSVC, but not in MinGW. Cast FARPROC to PGETCURRENTCONSOLEFONTEX to suppress MSVC compiler warning. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 9ca8039 commit a49c818

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compat/winansi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright 2008 Peter Harris <git@peter.is-a-geek.org>
33
*/
44

5+
#undef NOGDI
56
#include "../git-compat-util.h"
67
#include <malloc.h>
78
#include <wingdi.h>
@@ -30,6 +31,7 @@ static int negative;
3031
static FILE *last_stream = NULL;
3132
static int non_ascii_used = 0;
3233

34+
#ifdef __MINGW32__
3335
typedef struct _CONSOLE_FONT_INFOEX {
3436
ULONG cbSize;
3537
DWORD nFont;
@@ -38,6 +40,7 @@ typedef struct _CONSOLE_FONT_INFOEX {
3840
UINT FontWeight;
3941
WCHAR FaceName[LF_FACESIZE];
4042
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
43+
#endif
4144

4245
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
4346
PCONSOLE_FONT_INFOEX);
@@ -52,8 +55,8 @@ static void warn_if_raster_font(void)
5255
return;
5356

5457
/* GetCurrentConsoleFontEx is available since Vista */
55-
pGetCurrentConsoleFontEx = GetProcAddress(GetModuleHandle("kernel32.dll"),
56-
"GetCurrentConsoleFontEx");
58+
pGetCurrentConsoleFontEx = (PGETCURRENTCONSOLEFONTEX) GetProcAddress(
59+
GetModuleHandle("kernel32.dll"), "GetCurrentConsoleFontEx");
5760
if (pGetCurrentConsoleFontEx) {
5861
CONSOLE_FONT_INFOEX cfi;
5962
cfi.cbSize = sizeof(cfi);

0 commit comments

Comments
 (0)