]> granicus.if.org Git - nethack/commitdiff
fix tile2bmp build under mingw. Provide alternatives for Microsoft-specific macros...
authorDion Nicolaas <dion@nicolaas.net>
Thu, 16 Apr 2015 20:36:06 +0000 (22:36 +0200)
committerDion Nicolaas <dion@nicolaas.net>
Thu, 16 Apr 2015 20:36:06 +0000 (22:36 +0200)
sys/winnt/Makefile.gcc
win/win32/mhmain.c
win/win32/winhack.c

index 7aed22a507e8fbb66206899bb9ef981dcdbb087e..f4d6e197229f988b3ab80dcda8dc4e1aac853bfe 100644 (file)
@@ -595,7 +595,7 @@ $(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag \
         $(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll
 endif
        @echo Linking....
-       $(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS) -lstdc++
+       $(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS) -static -lstdc++
        $(subst /,\,@if exist $(O)install.tag del $(O)install.tag)
 
 
@@ -686,10 +686,10 @@ $(SRC)/vis_tab.c: $(U)makedefs.exe
 $(DAT)/engrave: $(DAT)/engrave.txt $(U)makedefs.exe
        $(subst /,\,$(U)makedefs -s)
 
-$(DAT)\epitaph: $(DAT)/epitaph.txt $(U)makedefs.exe
+$(DAT)/epitaph: $(DAT)/epitaph.txt $(U)makedefs.exe
        $(subst /,\,$(U)makedefs -s)
 
-$(DAT)\bogusmon: $(DAT)/bogusmon.txt $(U)makedefs.exe
+$(DAT)/bogusmon: $(DAT)/bogusmon.txt $(U)makedefs.exe
        $(subst /,\,$(U)makedefs -s)
 
 
@@ -999,7 +999,7 @@ $(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32)
        @$(link) $(LFLAGSU) -o$@ $(O)til2bm32.o $(TEXT_IO32)
 
 $(O)tile2bmp.o: $(WSHR)/tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)/win32api.h
-       $(cc) $(CFLAGS) -I$(WSHR) -o$@ $(WSHR)/tile2bmp.c
+       $(cc) $(CFLAGS) -mno-ms-bitfields -I$(WSHR) -o$@ $(WSHR)/tile2bmp.c
 
 $(O)til2bm32.o: $(WSHR)/til2bm32.c $(HACK_H) $(TILE_H) $(INCL)/win32api.h
        $(cc) $(CFLAGS) -I$(WSHR) -DTILE_X=32 -DTILE_Y=32 -o$@ $(WSHR)/til2bm32.c
index ae46fda31f15da40addc73cac6c9f4a9523a803e..88909224050b2ffe205efb17848a69f07b32d61f 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;
index c8498f08f298d2a5eebf29215334e9771dd1929f..13e3a6a3e8a898ec91640b8371424ff2bb890c80 100644 (file)
@@ -15,9 +15,8 @@
 #include "mhmain.h"
 #include "mhmap.h"
 
-#ifndef __BORLANDC__
-#include <shlwapi.h>
-#else /* Borland redefines "boolean" in shlwapi.h so just use the little bit we need */
+/* Borland and MinGW redefine "boolean" in shlwapi.h,
+   so just use the little bit we need */
 typedef struct _DLLVERSIONINFO
 {
     DWORD cbSize;
@@ -34,7 +33,7 @@ typedef struct _DLLVERSIONINFO
 
 typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
 
-#endif
+/* en of shlwapi.h */
 
 /* Minimal common control library version
 Version     _WIN_32IE   Platform/IE