[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem passing Array of Structs to external library


"Of" the array, not "if".

Jussi

On Thu, Apr 4, 2024 at 1:20 AM Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
wrote:

> Some mistakes. Object instead of embedded array and wrong order if the
> array.
> See the attachment.
>
>
> Jussi
>
>
> On Wed, Apr 3, 2024 at 8:00 PM T Lee Davidson <t.lee.davidson@xxxxxxxxx>
> wrote:
>
>> I'm working with an external library that allows to pass an array of
>> structures in the extra arguments of a variadic function.
>> It does not work well with the array of structures that I try passing to
>> it.
>>
>> With a C structure defined thusly:
>>
>> struct OptionItem
>> {
>>    int option;
>>    intptr_t value;
>>    void *ptr_value;
>> };
>>
>> ... it does work if a C function passes the following as "ops":
>>
>> struct OptionItem ops[] = {
>> { OPTION_CONNECTION_TIMEOUT, 31, NULL },
>> { OPTION_CONNECTION_LIMIT, 21, NULL },
>> { OPTION_CONNECTION_MEMORY_LIMIT, 11, NULL},
>> { OPTION_END, 0, NULL }
>> };
>>
>> Isn't that an array of structures?
>>
>> Strangely, if I pass it just a single structure (instead of an array), it
>> does not complain but actually parses it.
>>
>> Perhaps I am misunderstanding how this should work.
>>
>> I have taken source code from that shared library and pared it down to
>> create a small library that demonstrates the issue. It,
>> with its source code, is included in the project which is attached.
>>
>> --
>> Lee
>>
>> --- Gambas User List Netiquette [
>> https://gambaswiki.org/wiki/doc/netiquette] ----
>> --- Gambas User List Archive [https://lists.gambas-basic.org/archive/user]
>> ----
>>
>

Follow-Ups:
Re: Problem passing Array of Structs to external libraryJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
References:
Problem passing Array of Structs to external libraryT Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: Problem passing Array of Structs to external libraryJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>