win32_gui: remove macros and functions that are unsupported by gcc

This commit is contained in:
Alex Kompel
2015-04-19 16:34:22 -07:00
parent dc06a5dd90
commit 1e06a7c675

View File

@@ -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;