]> granicus.if.org Git - nethack/commitdiff
win32_gui: remove macros and functions that are unsupported by gcc
authorAlex Kompel <barbos+nethack@gmail.com>
Sun, 19 Apr 2015 23:34:22 +0000 (16:34 -0700)
committerAlex Kompel <barbos+nethack@gmail.com>
Sun, 19 Apr 2015 23:34:22 +0000 (16:34 -0700)
win/win32/mhmain.c

index 88909224050b2ffe205efb17848a69f07b32d61f..48662a03cef11a57fc5f1d71bb048aa593582b0a 100644 (file)
 #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;