From 1e06a7c675bf7b24081513decf241396dc175b07 Mon Sep 17 00:00:00 2001 From: Alex Kompel Date: Sun, 19 Apr 2015 16:34:22 -0700 Subject: [PATCH] win32_gui: remove macros and functions that are unsupported by gcc --- win/win32/mhmain.c | 48 ++-------------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 889092240..48662a03c 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -16,50 +16,6 @@ #include "mhmsgwnd.h" #include "mhmap.h" - -#ifdef __MINGW32__ -/* Force a compilation error if condition is true, but also produce a - result (of value 0 and type size_t), so the expression can be used - e.g. in a structure initializer (or where-ever else comma expressions - aren't permitted). */ -#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) -/* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) - -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) -#define _countof(arr) ARRAY_SIZE(arr) - -int _stprintf_s( - TCHAR*buffer, - size_t sizeOfBuffer, - const TCHAR *format , - ... - ) -{ - int ret; - va_list args; - - va_start (args, format); - ret = _vstprintf( buffer, format, args); - va_end(args); - return ret; -} - -double _wtof( const wchar_t *string ) -{ - double ret; - size_t len = wcslen(string) + 1; - char* p = (char*) malloc(len); - - wcstombs(p,string,len); - ret = atof(p); - free(p); - return ret; -} - -#endif - typedef struct mswin_nethack_main_window { int mapAcsiiModeSave; } NHMainWindow, *PNHMainWindow; @@ -912,7 +868,7 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; ofn.lpstrFile = filename; - ofn.nMaxFile = _countof(filename); + ofn.nMaxFile = SIZE(filename); ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NH_A2W(hackdir, whackdir, MAX_PATH); @@ -933,7 +889,7 @@ LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) pFile = _tfopen(filename, TEXT("wt+,ccs=UTF-8")); if( !pFile ) { TCHAR buf[4096]; - _stprintf_s(buf, _countof(buf), TEXT("Cannot open %s for writing!"), filename); + _stprintf(buf, TEXT("Cannot open %s for writing!"), filename); NHMessageBox(hWnd, buf, MB_OK | MB_ICONERROR); free(text); return FALSE;