Interface with C

Ana Maria Abrao ana@ufu.br
Tue, 02 Jun 1998 08:46:30 +0000


Dear Alan.

I am using Windows 95. As far as I know, you are using MacIntosh. It
is possible that MacIntosh doesn't have the foreingn interface. 
Any way, what I did was to write a program in Clean like the one shown
in module teste. Then, I compiled a program like tes.c. Since I
am using Microsoft Visual C++, I got an object called tes.obj. I 
renamed it to tes.o and inserted it into the Clean System Files
of teste. Finally, I chose Options/Link Options in Clean's task
menu and inserted {Project}:Clean System Files\tes.o. That is all.
Good Luck with the Mac.

Ana Abrão and Antonio Costa.


module teste;
import StdEnv;

gg:: !Int !Int -> !Int;
gg  _   _
= code
   {  .inline gg
         ccall  fn  "II-I"
      .end
    };

Start=  (gg  4   5);


********** C side ****************
int fn(int x, int x)
{ /* Do whatever you think it is fit. */
  return(x*x+y*y);}
 /*Return an integer, since  the signature of fn,
   declared in module teste, is "II-I".
   The first and second I of "II-I" shows the
   type of the arguments. The I after the
   minus sign is the type of the result. */