]> Shamusworld >> Repos - rmac/commitdiff
Fix to placate the Visual Studio(TM) gods. v2.2.17
authorShamus Hammons <jlhamm@acm.org>
Mon, 20 Mar 2023 19:57:12 +0000 (14:57 -0500)
committerShamus Hammons <jlhamm@acm.org>
Mon, 20 Mar 2023 19:57:12 +0000 (14:57 -0500)
N.B.: Even MXE (which makes Windows(TM) executables), doesn't need this
      kind of special treatment.  So, meh.  :-/

cross-compile
dirent_lose.c [new file with mode: 0644]
dirent_lose.h [new file with mode: 0644]
makefile
rmac.h
version.h

index 91fc44b0741cccc95c83156d57c11cc07464e07d..4e46f11d0632a9ced9ba88ef391f9e5ee91c439c 100755 (executable)
@@ -7,6 +7,7 @@
 #
 echo "Cross compiling for Win32..."
 export PATH=/opt/mxe/usr/bin:$PATH
-make CROSS=i686-pc-mingw32-
+#make CROSS=i686-pc-mingw32-
+make CROSS=i686-w64-mingw32.static-
 rel=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -`
 mv rmac rmac.exe && upx -9v rmac.exe && zip -9v rmac-$rel.zip rmac.exe
diff --git a/dirent_lose.c b/dirent_lose.c
new file mode 100644 (file)
index 0000000..716051b
--- /dev/null
@@ -0,0 +1,35 @@
+#if defined(WIN32) || defined(WIN64)
+
+// Microsoft™ Windows™ dependent code
+
+// There is one, and only one case where this is needed and that's in a Visual
+// Studio™ environment.  Even building a Windows™ executable with MXE doesn't
+// require this.  So, even though this kind of thing is POSIX, it can't be
+// included in a Visual Studio™ environment without adding a 3rd party shim.
+// So we've made our own shim.
+//
+// The shim is minimal because the code in RMAC that uses it is minimal.  If it
+// gets expanded in the future for some reason, the shim will have to expand
+// too.  :-/  But that will never happen, right?  ;-)
+//
+
+#include "dirent_lose.h"
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+static DIR dummy;
+
+DIR * opendir(const char * name)
+{
+       BOOL test = ((GetFileAttributesA(name) & FILE_ATTRIBUTE_DIRECTORY) != INVALID_FILE_ATTRIBUTES);
+
+       return (test ? &dummy : NULL);
+}
+
+int closedir(DIR * dir)
+{
+       return 0;
+}
+
+#endif
diff --git a/dirent_lose.h b/dirent_lose.h
new file mode 100644 (file)
index 0000000..3e6bef2
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __DIRENT_LOSE_H__
+#define __DIRENT_LOSE_H__
+
+#if defined(WIN32) || defined(WIN64)
+
+// Microsoft™ Windows™ dependent code
+
+// This is only needed to keep the compiler from throwing a fit, it's not meant
+// to be used except as a sentinel (NULL/non-NULL).
+typedef struct { int i; /* dummy member */ } DIR;
+
+// These are the only two functions used from <dirent.h>
+DIR * opendir(const char *);
+int closedir(DIR *);
+
+#endif
+
+#endif // __DIRENT_LOSE_H__
index 9f6d9ac3bb10944761e7511886bf4c31689c660f..094eff48f04bc5c5d799b2dc61f9e0c3cf7ae192 100644 (file)
--- a/makefile
+++ b/makefile
@@ -27,7 +27,7 @@ HOSTCC = gcc
 #CFLAGS = -std=$(STD) -D_DEFAULT_SOURCE -g -D__GCCUNIX__ -I. -O2 -MMD
 CFLAGS = -std=$(STD) -D_DEFAULT_SOURCE -g -D__GCCUNIX__ -I. -O2
 
-OBJS = 6502.o amode.o debug.o direct.o dsp56k.o dsp56k_amode.o dsp56k_mach.o eagen.o error.o expr.o fltpoint.o listing.o mach.o macro.o mark.o object.o op.o procln.o riscasm.o rmac.o sect.o symbol.o token.o
+OBJS = 6502.o amode.o debug.o direct.o dsp56k.o dsp56k_amode.o dsp56k_mach.o eagen.o error.o expr.o fltpoint.o listing.o mach.o macro.o mark.o object.o op.o procln.o riscasm.o rmac.o sect.o symbol.o token.o dirent_lose.o
 
 #
 # Build everything
@@ -162,3 +162,4 @@ symbol.o: symbol.c symbol.h error.h rmac.h listing.h object.h procln.h \
  token.h
 token.o: token.c token.h rmac.h symbol.h direct.h error.h macro.h \
  procln.h sect.h riscasm.h kwtab.h unarytab.h
+dirent_lose.o: dirent_lose.h
diff --git a/rmac.h b/rmac.h
index 00dcd3ba49c92cb9d6b6c194076adbe7c94bc4ef..48a6545c6d9ac0849b417d23ecd5a97575675cd2 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -22,6 +22,7 @@
 #if defined(WIN32) || defined(WIN64)
        #include <io.h>
        #include <fcntl.h>
+       #include "dirent_lose.h"
        // Release platform - windows
        #define PLATFORM        "Win32"
        #define _OPEN_FLAGS     _O_TRUNC|_O_CREAT|_O_BINARY|_O_RDWR
 
        #endif
 
+       // Ever since Visual Studio... 2017? 2019? the following constants come
+       // defined in the platform SDK, which leads to endless warnings from the
+       // compiler. So let's just put the pacifier on and undef them, sheesh! (No,
+       // we won't rename the defines, we've been here since 1986, Visual Studio
+       // wasn't even a glimpse in the milkman's eyes, if you catch my drift)
+       #undef CONST
+       #undef ERROR
+       #undef TEXT
+
 #else
 
+       #include <dirent.h>
+
        #ifdef __GCCUNIX__
 
        #include <sys/fcntl.h>
 // Non-target specific stuff
 //
 #include <inttypes.h>
-#include <dirent.h>
 #include "symbol.h"
 
-#if defined(WIN32) || defined(WIN64)
-// Ever since Visual Studio... 2017? 2019? the following constants come defined in the
-// platform SDK, which leads to endless warnings from the compiler. So let's just
-// put the pacifier on and undef them, sheesh! (No, we won't rename the defines,
-// we've been here since 1986, Visual Studio wasn't even a glimpse in the milkman's eyes,
-// if you catch my drift)
-#undef CONST
-#undef ERROR
-#undef TEXT
-#endif
-
 #define BYTE         uint8_t
 #define WORD         uint16_t
 #define LONG         uint32_t
index f9fe9873580c7c3a3b75a29b10b886bf2991d374..48787ae1bdf52f7965a9d96bbca261d310b5475a 100644 (file)
--- a/version.h
+++ b/version.h
@@ -15,6 +15,6 @@
 
 #define MAJOR   2              // Major version number
 #define MINOR   2              // Minor version number
-#define PATCH   16             // Patch release number
+#define PATCH   17             // Patch release number
 
 #endif // __VERSION_H__