[racket] newbie: foreign C structure definition question
It supports arrays in function arguments and returns. In that case, it
is only necessary for them to be sized as pointers. That sizing is why
they don't work nicely in structs.
I've complained about this before, which is why I was able to quickly
answer your question. I don't endorse the current behavior.
Jay
On Tue, Nov 16, 2010 at 9:06 PM, John Whittaker
<john.whittaker at kc.rr.com> wrote:
> Sorry.
>
> I forgot to say this last week when you replied: Thanks for the info!
>
> It is a bit surprising to me that the FFI does not support arrays. Is
> this on the list of future functionality?
>
> Thanks again,
>
> John Whittaker
>
>
> On 11/03/2010 11:59 PM, Jay McCarthy wrote:
>> Currently the FFI does not support this.
>>
>> I've simulated it in the past by making another struct with 32 char objects.
>>
>> I wrote a macro to automate it. Look at
>>
>> define-opencl-vector-alias
>>
>> from
>>
>> https://github.com/jeapostrophe/opencl/blob/master/c/tsyntax.rkt
>>
>> A use case:
>>
>> (define-opencl-vector-alias _cl_char 16)
>>
>> defines
>>
>> _cl_char16
>>
>> as a struct with 16 _cl_chars
>>
>> Jay
>>
>> On Wed, Nov 3, 2010 at 10:45 PM, John Whittaker
>> <john.whittaker at kc.rr.com> wrote:
>>> Hi Racket users,
>>>
>>> I am new to Racket Scheme, but not new to Scheme in general.
>>>
>>> I am trying to figure out how/if I can create a Racket C foreign
>>> structure representation of the following simple C struct using
>>> define-cstruct:
>>>
>>> struct X
>>> {
>>> int p1;
>>> char s1[32];
>>> };
>>>
>>>
>>> It is the nested array that I cannot figure how to represent. I have
>>> tried combing the Racket Guide and searched examples on the net, but I
>>> have not found anything. Does Racket support this or have I got too
>>> much newbie ignorance?
>>>
>>> Thanks,
>>>
>>> John Whittaker
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://lists.racket-lang.org/listinfo/users
>>>
>>
>>
>>
>
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93