[m-dev.] Re: exported functions which have a foreign type

Simon Taylor stayl at cs.mu.OZ.AU
Thu Jul 11 03:33:26 AEST 2002


On 10-Jul-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> I am willing to fix this bug.

[C compiler errors where a `:- pragma foreign_type' refers to a C
type which is not in scope where it is used in the prototype
for a predicate with a `:- pragma export' declaration]
 
> The problem is that the type definition is not visible for the
> foreign_type in the automatically generated header files.  However first
> could you let me know what should be in the .mh, .mih files, so that I
> can work out what the correct fix is.

The declarations can't go in the `.mih' file.
`mmc --make' assumes that changes to a module which cause
changes to the `.mih' file which would require the generated
C code for importing modules to be recompiled woould also cause
changes in the interface file. This assumption is necessary
to maintain separate compilation of the generated C files.
(Separate compilation of the generated C files in hlc grades
doesn't work with Mmake because there's no easy way to encode
that assumption in an Mmakefile).

I think the best thing to do is to write the `:- pragma foreign_decl'
declarations to the `.mh' file for all modules defining foreign types.
The main problem with this approach would be lots of unnecessary
recompilations of the generated C files when a `:- pragma foreign_decl'
changes. It might be better to have a separate
`:- pragma foreign_type_decl' declaration containing declarations
and #includes used only by foreign types, and only write that to the
`.mh' file.

I don't know enough about the IL or Java backends to know
what to do in those cases (if this is a problem at all for
those backends).

Simon.
--------------------------------------------------------------------------
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