changeset 360:ade217fd76a5

Use #define instead of const int to avoid issues with some compilers It's not strictly kosher in older C specs to use a "const int" to define an array. For improved portability, switch several "const int" constants to "#define" constants to avoid such problems. Thanks to Erik G <erik@6809.org> for pointing this out.
author William Astle <lost@l-w.ca>
date Tue, 26 May 2015 17:51:00 -0600
parents f318407d2469
children 4130ffdeb5c8
files lwasm/output.c
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/output.c	Tue May 26 17:49:26 2015 -0600
+++ b/lwasm/output.c	Tue May 26 17:51:00 2015 -0600
@@ -23,7 +23,10 @@
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
+
+#ifndef _MSC_VER
+#include <unistd.h>  // for unlink
+#endif
 
 #include <lw_alloc.h>
 #include <lw_expr.h>
@@ -303,16 +306,16 @@
 
 void write_code_srec(asmstate_t *as, FILE *of)
 {
-	const int SRECLEN = 16;
-	const int HDRLEN = 51;
+	#define SRECLEN 16
+	#define HDRLEN 51
 	
 	line_t *cl;
 	char outbyte;
 	int outaddr;
 	int rc;
-	int i;
+	unsigned int i;
 	int recaddr = 0;
-	int recdlen = 0;
+	unsigned int recdlen = 0;
 	unsigned char recdata[SRECLEN];
 	int recsum;
 	int reccnt = -1;
@@ -415,7 +418,7 @@
 
 void write_code_ihex(asmstate_t *as, FILE *of)
 {
-	const int IRECLEN = 16;
+	#define IRECLEN 16
 	
 	line_t *cl;
 	char outbyte;