Why does it does not work?
Madhu
enometh at meer.net
Thu Jun 8 15:11:53 UTC 2023
* oleg harput <CADvZWFL1TxpgbO9OzkJCwgDbXmKgB3TLwpeA7711tykgXH+npA at mail.gmail.com>
Wrote on Thu, 8 Jun 2023 17:05:29 +0300
> Hi. I want to use the following C function:
>
> ;; void ClearBackground(Color color);
[snip]
> (cffi:defcstruct %color
> (r :uint8)
> (g :uint8)
> (b :uint8)
> (a :uint8))
>
> (defvar *%lightgray* (cffi:foreign-alloc '(:struct %color)))
>
> ;; void ClearBackground(Color color);
> (cffi:defcfun ("ClearBackground" %clear-background) :void
> (color (:struct %color)))
>
> (defun clear-background (color)
> (%clear-background color))
>
> But when i run
>
> (clear-background *%lightgray*)
You are passing a pointer to a function which takes a struct by value.
you should be trying
```
(clear-background (cffi:mem-ref *%lightgray* '(:struct %color)))
```
> That does not work, I have already added my .asd file ":cffi-libffi" as
> dependency.
>
> What is the problem? If this issue has no solution, is there an alternate
> way?
Does the proposed form? If it does not, please follow up.
---
More information about the cffi-devel
mailing list