def-foreign-call question

Ronald Sudomo <[email protected]> Fri, 14 Oct 2005 12:37:39 -0600
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Hi all,

I got an unexpected result when calling a foreign function from a  
compiled Lisp function.

The following is the C declaration of the function (It's from  
QuickTime API):

typedef signed short SInt16;
typedef SInt16 OSErr;

EXTERN_API( OSErr )
EnterMovies(void);


This is what my def-foreign-call looks like:

(def-foreign-call (EnterMovies "EnterMovies")
    (:void)
  :returning :short
  :strings-convert t
  :call-direct t
  :optimize-for-space t)


If I call it from the listener: (EnterMovies) returns 0 (means no error)

Now let's say I define the following function:
(defun foo ()
    (EnterMovies))

In the listener: (foo) returns 0

But here is the problem, if I compile foo and call it again it  
returns 152371200 (in binary: 1001000101010000000000000000)
The low 16 bits are all zeros as expected. But why does it return a  
value that is more than 16 bits?

Any insights is appreciated. I'm using ACL 7.0 on Windows XP Pro, by  
the way.

Thanks!

Ronald