Newsgroups: comp.lang.lisp.mcl
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!news-e2a.gnn.com!howland.erols.net!vixen.cso.uiuc.edu!uchinews!news
From: wiseman@cs.uchicago.edu (John Wiseman)
Subject: Re: Floats and foreign functions
In-Reply-To: John Wiseman's message of Tue, 17 Sep 1996 12:15:43 -0500
X-Nntp-Posting-Host: gargoyle.cs.uchicago.edu
Message-ID: <arxohj5c9fa.fsf@gargoyle164.cs.uchicago.edu>
Lines: 34
Sender: wiseman@gargoyle164.cs.uchicago.edu
Reply-To: j-wiseman@nwu.edu
Organization: University of Chicago -- Academic Computing Services
X-Newsreader: Gnus v5.1
References: <323EDCB7.4A1C@nwu.edu>
Date: Tue, 17 Sep 1996 17:56:25 GMT

[New and improved, with only 7/8 the bits!]

   Hello.

   I'm having trouble passing floating point values to and returning
   floating point values from foreign functions using MCL 3.9.

   Specifically, say I have a function that was written in C and is located
   in a shared library.  The function uses the following declarations: 


   struct foo_struct {
	   float x;
   };

   float foo_function (struct foo_struct *z);


   When I define a record corresponding to foo_struct, what mactype should
   its x field be?  And how do I put the C equivalent of a Lisp floating
   point number in that field?

   I've tried defining fields using the :float_t, :double_t and :extended
   mactypes, but they don't allow themselves to be initialized with an
   expression like "1.0" and I don't see a "%put-float"-like function
   anywhere.

   Finally, of course, I need to bring the float returned by foo_function
   back into Lisp.  Is %copy-float the way to go?


   Thanks for your help,
   John

