[m-rev.] for review: disallow `#if' in C `pragma foreign_type'
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Dec 30 21:34:48 AEDT 2003
Estimated hours taken: 0.75
Branches: main
Document that C preprocessor directives are not permitted in C
`pragma foreign_type' declarations.
doc/reference_manual.texi:
Document that C preprocessor directives are not permitted in
C `pragma foreign_type' declarations. This is needed because we
generate uses of foreign types inside macro invocations, e.g.
MR_MAYBE_BOX_FOREIGN_TYPE(), and the ISO C standard does not
permit preprocessor directives inside macro invocations.
(It would be nicer for the compiler to generate a C typedef,
and then generate references to the typedef name inside
MR_MAYBE_BOX_FOREIGN_TYPE() rather than copying the user's type
definition directly. But it's not very important, and this
is an easier fix.)
Also, some minor clarifications to the documentation for
C and Java `foreign_type' pragmas.
Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.285
diff -u -d -r1.285 reference_manual.texi
--- doc/reference_manual.texi 23 Dec 2003 02:53:09 -0000 1.285
+++ doc/reference_manual.texi 30 Dec 2003 10:27:49 -0000
@@ -6019,7 +6019,13 @@
A C @samp{pragma foreign_type} declaration has the form:
@example
-:- pragma foreign_type("C", @var{MercuryTypeName}, @var{CForeignType}).
+:- pragma foreign_type("C", @var{MercuryTypeName}, "@var{CForeignType}").
+ at end example
+
+For example,
+
+ at example
+:- pragma foreign_type("C", long_double, "long double").
@end example
The @var{CForeignType} can be any C type name that obeys the following
@@ -6031,6 +6037,9 @@
@samp{void (*)(void)}. However, it would be OK to use a typedef name
which was defined as a function pointer type.)
+C preprocessor directives (such as @samp{#if}) may not be used in
+ at var{CForeignType}.
+
@strong{With @samp{--gc accurate}, foreign_types which are C pointer types
must not point to the Mercury heap.}
@@ -6316,7 +6325,7 @@
A Java @samp{pragma foreign_type} declaration has the form:
@example
-:- pragma foreign_type("Java", @var{MercuryTypeName}, @var{JavaType}).
+:- pragma foreign_type("Java", @var{MercuryTypeName}, "@var{JavaType}").
@end example
The @var{JavaType} can be any accessible Java type.
--
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-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