[m-rev.] for review: fix foreign_types and pragma export

Simon Taylor stayl at cs.mu.OZ.AU
Wed Jul 24 02:46:08 AEST 2002


On 23-Jul-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Sun, Jul 21, 2002 at 12:52:57PM +1000, Simon Taylor wrote:
> > A much better way to deal with this would be to write the
> > foreign_decls to both the `.mh' file (without line numbers) and
> > the C or `.mih' file (with line numbers). That would allow errors
> > to be reported with the correct line numbers when compiling the
> > module containing the foreign_decl, but wouldn't cause unnecessary
> > recompilation of the C code for importing modules.
 
> Estimated hours taken: 2
> Branches: main
> 
> Place the decls both in the .mh file and in either the .c (LLDS) or .mih (HLDS) file protected with a #ifndef/#define block.

> Index: compiler/mlds_to_c.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
> retrieving revision 1.132
> diff -u -r1.132 mlds_to_c.m
> --- compiler/mlds_to_c.m	21 Jun 2002 13:26:42 -0000	1.132
> +++ compiler/mlds_to_c.m	23 Jul 2002 08:51:19 -0000
> @@ -551,7 +551,10 @@
>  	{ ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports,
>  		_RevBodyCode, _ExportDefns) },
>  	{ HeaderCode = list__reverse(RevHeaderCode) },
> -	io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)).
> +	io__write_strings(["#ifndef ", decl_guard(ModuleName),
> +		"\n#define", decl_guard(ModuleName), "\n"]),
> +	io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)),
> +	io__write_string("#endif\n").
>  
>  :- pred mlds_output_c_hdr_decl(indent,
>  	foreign_decl_code, io__state, io__state).

This doesn't even compile. I've backed out the change.

You will need to strip off the "mercury" prefix on the module
name for the standard library modules so that the header guards
in the `.mh' and `.mih' files are the same.

The `#include's generated for the current module's `.mih' and
`.mh' file by mlds_output_src_start are in the wrong order.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list