trivial diff: fix warnings

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Sep 19 15:32:19 AEST 1998


Fix up some C code in the library that was causing warnings
from gcc.

library/io.m:
	Change the return type of mercury_output_error()
	from `int' to `void', since it never returns, and also
	to avoid a warning.

library/library.m:
	Add a cast to the C code for library__version, to avoid
	a warning.  Remove some unnecessary casts.

Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.163
diff -u -r1.163 io.m
--- io.m	1998/09/09 06:05:07	1.163
+++ io.m	1998/09/19 05:21:20
@@ -1324,10 +1324,10 @@
 		}
 	}
 	if (Res == 0) {
-		incr_hp_atomic(RetString,
+		incr_hp_atomic(LVALUE_CAST(Word, RetString),
 			ML_IO_BYTES_TO_WORDS((i + 1) * sizeof(Char)));
-		memcpy((void *) RetString, read_buffer, i * sizeof(Char));
-		((Char *) RetString)[i] = '\\0';
+		memcpy(RetString, read_buffer, i * sizeof(Char));
+		RetString[i] = '\\0';
 	} else {
 		RetString = NULL;
 	}
@@ -2493,7 +2493,7 @@
 void 		mercury_init_io(void);
 MercuryFile*	mercury_open(const char *filename, const char *type);
 void		mercury_fatal_io_error(void);
-int		mercury_output_error(MercuryFile* mf);
+void		mercury_output_error(MercuryFile* mf);
 void		mercury_print_string(MercuryFile* mf, const char *s);
 void		mercury_print_binary_string(MercuryFile* mf, const char *s);
 int		mercury_getc(MercuryFile* mf);
@@ -2550,7 +2550,7 @@
 
 :- pragma c_code("
 
-int
+void
 mercury_output_error(MercuryFile* mf)
 {
 	fprintf(stderr,
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.41
diff -u -r1.41 library.m
--- library.m	1998/04/15 06:48:17	1.41
+++ library.m	1998/09/19 05:12:51
@@ -41,8 +41,15 @@
 % at configuration time, because that would cause bootstrapping problems --
 % might not have a Mercury compiler around to compile library.m with.
 
-:- pragma c_code(library__version(Version::out), will_not_call_mercury,
-	"Version = MR_VERSION "", configured for "" MR_FULLARCH;").
+:- pragma c_code(library__version(Version::out), will_not_call_mercury, "
+	ConstString version_string = 
+		MR_VERSION "", configured for "" MR_FULLARCH;
+	/*
+	** Cast away const needed here, because Mercury declares Version
+	** with type String rather than ConstString.
+	*/
+	Version = (String) (Word) version_string;
+").
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list