[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Foreign functions and const specifier
From: |
Peter Bex |
Subject: |
[Chicken-users] Foreign functions and const specifier |
Date: |
Wed, 29 Dec 2004 19:02:36 +0100 |
User-agent: |
Mutt/1.4.2.1i |
Hi list,
I was creating Chicken wrapper for a C library, and I came across a very
mysterious phenomenon:
(define-foreign-type epeg-image (pointer "Epeg_Image")) ; not important
(define epeg-file-open
(foreign-lambda image epeg-image epeg_file_open (const c-string)))
When I (require 'epeg) from csi, and call the function on an existing
file, I got #f. When I tried it again (calling the same function without
changing ANYTHING), suddenly it returned a valid pointer.
$ csi
<snip>
csi> (require 'epeg)
; loading ./epeg.so ...
csi> (epeg-file-open "test.jpg") ; test.jpg exists!
#f
csi> (epeg-file-open "test.jpg")
#<pointer 18fe800>
csi> (epeg-file-open "test.jpg")
#f
Doing so repeatedly gives me a valid pointer about 80% of the time, and
#f the remaining 20%. I now removed the const specifier:
(define epeg_file_open
(foreign-lambda image image epeg_file_open c-string))
Suddenly it returned no more #f's, only valid pointers.
Can someone explain to me why this is happening?
Greetz,
Peter Bex
--
http://www.student.kun.nl/peter.bex
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgp8rRBTB5kPF.pgp
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Chicken-users] Foreign functions and const specifier,
Peter Bex <=