Ah, of course, John! I got them mixed up.
In that case Chris, I think your color struct might fit quite nicely into a
make-s32vector. I did not test the code below, but something like it might
work:
(define-foreign-type color* s32vector
(lambda (a) (assert (= 4 (s32vector-length a))) a))
(define color s32vector)
(define (rgb-to-hsl color)
(let ((return (make-s32vector 3)))
((foreign-lambda*
void ((color input) (color output))
"rgb_to_hsl((struct color*)input, &output[0], &output[1],
&output[2])") color return)
return))
(rgb-to-hsl (color 0 255 0 0)) ;; <-- should in theory return a
;; 3-element s32vector with your hue,
;; sat and lum.
Note the cast from s32vector (int*) to struct color*.
Cheers,
K.
On Sat, Sep 7, 2013 at 4:33 PM, John Cowan <[email protected]> wrote:
> Kristian Lein-Mathisen scripsit:
>
> > Because size of an "int" can generally be either 32 or 64-bit depending
> > on your architecture, the srfi-4 vectors are possible better suited
> > for floats and doubles where the sizes are all set. It's worth knowing
> > about them though.
>
> Actually, there are essentially no architectures on which "int" is
> anything but 32 bits: unless you have an ancient Cray running Unicos
> (modern ones run Linux), a (now-defunct) HAL Systems port of Solaris,
> or an IBM PC/AT, you don't have to worry about that. What does vary is
> "long", which is 32 bits on 32-bit systems and Win64, and 64 bits on
> non-Windows 64-bit systems.
>
> --
> John Cowan http://ccil.org/~cowan [email protected]
> SAXParserFactory [is] a hideous, evil monstrosity of a class that should
> be hung, shot, beheaded, drawn and quartered, burned at the stake,
> buried in unconsecrated ground, dug up, cremated, and the ashes tossed
> in the Tiber while the complete cast of Wicked sings "Ding dong, the
> witch is dead." --Elliotte Rusty Harold on xml-dev
>
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users