[m-rev.] for review: fix MSVC LLDS code compilation

Peter Ross pro at missioncriticalit.com
Mon May 28 09:32:07 AEST 2007


Zoltan,

Could you just check the following.
It doesn't give any warnings under gcc.


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


Estimated hours taken: 2
Branches: main

Fixes to make the compiler compile using MSVC in the LLDSgrades.

compiler/llds_out.m:
	MSVC treats declarations such as
		"static const struct s a[];"
	as definitions.  As a definition it doesn't know the size
	of the definition, so aborts.
	Thus we now output
		"extern const struct s a[];"
	which both gcc and msvc seem to handle.
	
runtime/mercury_stack_layout.h:
	The MSVC C pre-processor aborts on comments inside C
	pre-processor #defines, eg
		#define P(X) Q(/* extern */, X)
	It seems to treat strip the comment and then complain
	about the missing argument.
	The comment is no replaced with a pre-processor simple
	which evaluates to the empty string.

	


Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.306
diff -u -r1.306 llds_out.m
--- compiler/llds_out.m	7 May 2007 05:21:31 -0000	1.306
+++ compiler/llds_out.m	27 May 2007 10:08:57 -0000
@@ -1168,7 +1168,7 @@
     io.write_string("\n", !IO),
     output_common_type_defn(TypeNum, CellType, !DeclSet, !IO),
     VarDeclId = decl_scalar_common_array(TypeNum),
-    io.write_string("static const struct ", !IO),
+    io.write_string("extern const struct ", !IO),
     output_common_cell_type_name(TypeNum, !IO),
     io.write_string(" ", !IO),
     output_common_scalar_cell_array_name(TypeNum, !IO),
@@ -1185,7 +1185,7 @@
     output_common_type_defn(TypeNum, CellType, !DeclSet, !IO),
     VarDeclId = decl_data_addr(data_addr(ModuleName,
         vector_common_ref(TypeNum, CellNum))),
-    io.write_string("static const struct ", !IO),
+    io.write_string("extern const struct ", !IO),
     output_common_cell_type_name(TypeNum, !IO),
     io.write_string(" ", !IO),
     output_common_vector_cell_array_name(TypeNum, CellNum, !IO),
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.110
diff -u -r1.110 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h	19 Jan 2007 04:42:46 -0000	1.110
+++ runtime/mercury_stack_layout.h	27 May 2007 10:08:57 -0000
@@ -1212,6 +1212,8 @@
 		(MR_ProcStatic *) proc_static				\
 	}
 
+#define MR_NO_EXTERN_DECL
+
 #define MR_STATIC_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
 		pf, module, name, arity, mode)				\
 	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(static, detism, slots,	\
@@ -1219,7 +1221,7 @@
 		&MR_proc_static_user_name(module, name, arity, mode))
 #define MR_EXTERN_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
 		pf, module, name, arity, mode)				\
-	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots, \
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots,\
 		succip_locn, pf, module, name, arity, mode,		\
 		&MR_proc_static_user_name(module, name, arity, mode))
 
@@ -1230,7 +1232,7 @@
 		&MR_proc_static_uci_name(module, name, type, arity, mode))
 #define MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
 		module, name, type, arity, mode)			\
-	MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots,\
+	MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots,\
 		succip_locn, module, name, type, arity, mode,		\
 		&MR_proc_static_uci_name(module, name, type, arity, mode))
 
@@ -1240,7 +1242,7 @@
 		succip_locn, pf, module, name, arity, mode, NULL)
 #define MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(detism, slots, succip_locn,	\
 		pf, module, name, arity, mode)				\
-	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots,\
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(MR_NO_EXTERN_DECL, detism, slots,\
 		succip_locn, pf, module, name, arity, mode, NULL)
 
 #define MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(mod, n, a)                       \

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list