[mercury-users] rotd-2002-12-03 -- C interface problem
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Dec 12 01:04:38 AEDT 2002
On 10-Dec-2002, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> I recently switched from rotd-2002-09-24 to rotd-2002-12-03 and there is
> something new with the C interface.
>
> First of all: mmc now generates .mh and .mih files for every module
> (even if it doesn't export anything for C) and mmc has stopped generating
> .h files for modules than *do* export some functions.
>
> What are the .mh and .mih files and what should I fix to get .h files as
> well? (So far I do #include .mh instead of .h and it worked in some
> cases.)
The `.mh' files are intended to replace the `.h' files.
We switched from using `.h' to avoid name clashes between the names
of standard C header files and header files for Mercury modules
that export stuff to C, e.g. with `math.h', `float.h', etc.
This is documented in the NEWS file:
| * The automatically generated header files for modules containing
| `pragma export' declarations are now named `<module>.mh', not
| `<module>.h'. This avoids conflicts with system header files.
So yes, the idea is that you should do #include .mh.
The `.mih' files are implementation details (.mih stands for
"Mercury Implementation Header") that users shouldn't need to
worry about. They are used for the --high-level-code back-end.
> And the second question is a bit foolish: My source code of a project is
> rather untidy; I had to export my own predicates to construct mercury
> lists from C++ (the default macros worked in C only, is that still true
> with rotd-2002-12-03?).
I don't know off-hand; I suspect it is probably possible to make them
work in C++. But explicitly exporting them is likely to be a more robust
solution.
> But now, the modules don't compile. Is this my fault?
...
> Listing follows:
>
> mgnuc --high-level-code --c-debug --no-c-optimize -I ../milan -I
> ../../../src/ent/mikulas/simple/ -- -I../../../src/shared/ -I.
> -I../../../src/shared/comm/ -I../../../src/ent/mikulas/simple/ -g -c
> db_cint.cc
> gcc: Ambiguous abbreviation --
The problem here is that you have included `-I' options in `MGNUCFLAGS',
rather than in `CFLAGS'. `-I' options are interpreted by the C compiler,
not the mgnuc script, so they need to go in `CFLAGS'.
However, I don't think that explains the other errors.
They look like they may be due to a recently-introduced bug
in the ROTD release(?).
I think the following patch (which I can't test right now -- our
development machines are in the process of being moved to a new building)
should hopefully fix it.
Index: mercury_stack_layout.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.65
diff -u -d -u -r1.65 mercury_stack_layout.h
--- mercury_stack_layout.h 2002/11/15 04:50:40 1.65
+++ mercury_stack_layout.h 2002/12/11 13:55:49
@@ -33,6 +33,8 @@
#include "mercury_std.h" /* for MR_VARIABLE_SIZED */
#include "mercury_tags.h"
#include "mercury_type_info.h" /* for MR_PseudoTypeInfo */
+#include "mercury_tabling.h" /* for MR_TableNodeUnion,
+ needed for MR_TrieNode */
/*-------------------------------------------------------------------------*/
/*
Index: mercury_type_info.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.97
diff -u -d -u -r1.97 mercury_type_info.h
--- mercury_type_info.h 2002/11/21 15:14:40 1.97
+++ mercury_type_info.h 2002/12/11 13:48:01
@@ -102,7 +102,6 @@
typedef struct MR_TypeInfo_Almost_Struct *MR_TypeInfo;
typedef const struct MR_PseudoTypeInfo_Almost_Struct *MR_PseudoTypeInfo;
typedef const void *MR_ReservedAddr;
-typedef union MR_TrieNode *MR_TrieNodePtr;
#ifdef MR_HIGHLEVEL_CODE
typedef MR_Box MR_BaseTypeclassInfo;
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list