comparison lwasm/output.c @ 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 d4ac484d0ec6
children 4411a6123716
comparison
equal deleted inserted replaced
359:f318407d2469 360:ade217fd76a5
21 Contains the code for actually outputting the assembled code 21 Contains the code for actually outputting the assembled code
22 */ 22 */
23 #include <errno.h> 23 #include <errno.h>
24 #include <stdio.h> 24 #include <stdio.h>
25 #include <string.h> 25 #include <string.h>
26 #include <unistd.h> 26
27 #ifndef _MSC_VER
28 #include <unistd.h> // for unlink
29 #endif
27 30
28 #include <lw_alloc.h> 31 #include <lw_alloc.h>
29 #include <lw_expr.h> 32 #include <lw_expr.h>
30 33
31 #include "lwasm.h" 34 #include "lwasm.h"
301 304
302 /* Motorola S19 hex file format */ 305 /* Motorola S19 hex file format */
303 306
304 void write_code_srec(asmstate_t *as, FILE *of) 307 void write_code_srec(asmstate_t *as, FILE *of)
305 { 308 {
306 const int SRECLEN = 16; 309 #define SRECLEN 16
307 const int HDRLEN = 51; 310 #define HDRLEN 51
308 311
309 line_t *cl; 312 line_t *cl;
310 char outbyte; 313 char outbyte;
311 int outaddr; 314 int outaddr;
312 int rc; 315 int rc;
313 int i; 316 unsigned int i;
314 int recaddr = 0; 317 int recaddr = 0;
315 int recdlen = 0; 318 unsigned int recdlen = 0;
316 unsigned char recdata[SRECLEN]; 319 unsigned char recdata[SRECLEN];
317 int recsum; 320 int recsum;
318 int reccnt = -1; 321 int reccnt = -1;
319 char rechdr[HDRLEN]; 322 char rechdr[HDRLEN];
320 323
413 416
414 /* Intel hex file format */ 417 /* Intel hex file format */
415 418
416 void write_code_ihex(asmstate_t *as, FILE *of) 419 void write_code_ihex(asmstate_t *as, FILE *of)
417 { 420 {
418 const int IRECLEN = 16; 421 #define IRECLEN 16
419 422
420 line_t *cl; 423 line_t *cl;
421 char outbyte; 424 char outbyte;
422 int outaddr; 425 int outaddr;
423 int rc; 426 int rc;