[m-rev.] for review: disallow `#if' in C `pragma foreign_type'

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jan 5 18:32:31 AEDT 2004


On 05-Jan-2004, Peter Moulder <Peter.Moulder at infotech.monash.edu.au> wrote:
> > +C preprocessor directives (such as @samp{#if}) may not be used in
> > + at var{CForeignType}.
> > +
> 
> We could add a suggested alternative, perhaps words to the effect
> 
>   (Instead, you may use a typedef or macro whose definition is in a
>   header file, perhaps inside `#if'.)

Estimated hours taken: 0.75
Branches: main

doc/reference_manual.texi:
	Document that entities declared in `pragma foreign_decl'
	declarations scope over `pragma foreign_type' declarations.

	Explain how to work around the restriction that C `pragma
	foreig_type' declarations can't contain preprocessor declarations.

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.286
diff -u -d -r1.286 reference_manual.texi
--- doc/reference_manual.texi	4 Jan 2004 21:50:45 -0000	1.286
+++ doc/reference_manual.texi	5 Jan 2004 07:29:19 -0000
@@ -5772,9 +5772,9 @@
 language, if appropriate).
 
 Entities declared in @samp{pragma foreign_decl} declarations are
-visible in @samp{pragma foreign_code} and @samp{pragma foreign_proc}
-declarations that specify the same foreign language and occur in the
-same Mercury module.
+visible in @samp{pragma foreign_code}, @samp{pragma foreign_type},
+and @samp{pragma foreign_proc} declarations that specify the same foreign
+language and occur in the same Mercury module.
 
 To make the declarations for Mercury predicates or functions
 exported to a foreign language using a @samp{pragma export}
@@ -5941,8 +5941,9 @@
 @subsubsection Using pragma foreign_decl for C
 
 Any macros, function prototypes, or other C declarations
-that are used in @samp{foreign_code} or @samp{foreign_proc} 
-pragmas must be included using a @samp{foreign_decl} declaration of the form
+that are used in @samp{foreign_code}, @samp{foreign_type}
+or @samp{foreign_proc} pragmas must be included using a
+ at samp{foreign_decl} declaration of the form
 
 @example
 :- pragma foreign_decl("C", @var{HeaderCode}).
@@ -6038,7 +6039,10 @@
 which was defined as a function pointer type.)
 
 C preprocessor directives (such as @samp{#if}) may not be used in
- at var{CForeignType}.
+ at var{CForeignType}.  (You can however use a typedef name that refers
+to a type defined in a @samp{pragma foreign_decl} declaration, and
+the @samp{pragma foreign_decl} declaration may contain C preprocessor
+directives.)
 
 @strong{With @samp{--gc accurate}, foreign_types which are C pointer types
 must not point to the Mercury heap.}

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