fsvb and foreign-typedefs with aggregate types

Madhu enometh at meer.net
Thu Feb 20 15:08:44 UTC 2020


*  Luís Oliveira <luismbo at gmail.com> <CAB-HnLS=k2wUnomOZ-U4Sov6OfTG4zJkc+mQAhnPBAqWdYXSyw at mail.gmail.com>
Wrote on Thu, 20 Feb 2020 13:28:45 +0000

> On Thu, 20 Feb 2020 at 09:31, Madhu <enometh at meer.net> wrote:
>> struct s_s_ch the_s_s_ch = { 2, { 1 } };
>> (defcvar "the_s_s_ch" s-s-ch) -> *s-s-ch* gets translated to a list.
> And perhaps it should, why not?

Because unlike aggregate struct values which are passed on the stack,
such a variable generally represents a mutable memory
location.

defcvar would no longer define a variable that reflects access to the
object on the C side.

so instead of (setf (foreign-slot-value *s-s-ch* 's-s-ch 'another-char) #\a)
one would have to do
(setf (foreign-slot-value (foreign-symbol-pointer "the_s_s_ch")
       's-s-ch 'another-char) #\a)

This pretty painful when the nesting gets deep.  I started trying to
convert the tests and I stopped around struct.alignment.4



More information about the cffi-devel mailing list