[m-dev.] for review: more empty array initializers

Peter Ross peter.ross at miscrit.be
Tue Feb 6 02:13:08 AEDT 2001


Hi,

For Zoltan to review.

===================================================================


Estimated hours taken: 1

Fix a problem where the none.gc.tr.debug grade doesn't compile using
MSVC.

compiler/layout_out.m:
    Avoid generating definitions in the following form
        type name[] = { };
    as not all C compilers (read MSVC) like an empty initializer list.


Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.1
diff -u -r1.1 layout_out.m
--- compiler/layout_out.m	2001/01/18 01:18:44	1.1
+++ compiler/layout_out.m	2001/02/05 15:06:48
@@ -619,7 +619,11 @@
 	output_layout_name_storage_type_name(proc_layout_var_names(ProcLabel),
 		yes),
 	io__write_string(" = {\n"),
-	list__foldl(output_number_in_vector, VarNames),
+	( { VarNames = [] } ->
+		io__write_string("\t0\n")
+	;
+		list__foldl(output_number_in_vector, VarNames)
+	),
 	io__write_string("};\n"),
 	{ decl_set_insert(DeclSet0, data_addr(
 		layout_addr(proc_layout_var_names(ProcLabel))), DeclSet) }.
@@ -764,9 +768,13 @@
 	io__write_string("\n"),
 	output_layout_name_storage_type_name(VectorName, yes),
 	io__write_string(" = {\n"),
-	list__foldl(
-		output_layout_name_in_vector("(const MR_Proc_Layout *)\n\t&"),
-		ProcLayoutNames),
+	( { ProcLayoutNames = [] } ->
+		io__write_string("\tNULL\n")
+	;
+		list__foldl(output_layout_name_in_vector(
+					"(const MR_Proc_Layout *)\n\t&"),
+				ProcLayoutNames)
+	),
 	io__write_string("};\n"),
 	{ decl_set_insert(DeclSet1, data_addr(layout_addr(VectorName)),
 		DeclSet) }.
@@ -832,7 +840,11 @@
 	io__write_string("\n"),
 	output_layout_name_storage_type_name(VectorName, yes),
 	io__write_string(" = {\n"),
-	list__foldl(output_layout_name_in_vector("&"), FileLayoutNames),
+	( { FileLayoutNames = [] } ->
+		io__write_string("\tNULL\n")
+	;
+		list__foldl(output_layout_name_in_vector("&"), FileLayoutNames)
+	),
 	io__write_string("};\n"),
 	{ decl_set_insert(DeclSet1, data_addr(layout_addr(VectorName)),
 		DeclSet) }.
@@ -892,7 +904,11 @@
 	io__write_string("\n"),
 	output_layout_name_storage_type_name(LayoutName, yes),
 	io__write_string(" = {\n"),
-	list__foldl(output_number_in_vector, LineNumbers),
+	( { LineNumbers = [] } ->
+		{ error("output_file_layout_line_number_vector_defn") }
+	;
+		list__foldl(output_number_in_vector, LineNumbers)
+	),
 	io__write_string("};\n"),
 	{ decl_set_insert(DeclSet0, data_addr(layout_addr(LayoutName)),
 		DeclSet) }.
@@ -907,9 +923,13 @@
 	io__write_string("\n"),
 	output_layout_name_storage_type_name(LayoutName, yes),
 	io__write_string(" = {\n"),
-	list__foldl(
-		output_data_addr_in_vector("(const MR_Label_Layout *)\n\t&"),
-		LabelAddrs),
+	( { LabelAddrs = [] } ->
+		io__write_string("\tNULL\n")
+	;
+		list__foldl(output_data_addr_in_vector(
+				"(const MR_Label_Layout *)\n\t&"),
+			LabelAddrs)
+	),
 	io__write_string("};\n"),
 	{ decl_set_insert(DeclSet0, data_addr(layout_addr(LayoutName)),
 		DeclSet) }.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list