[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem passing Array of Structs to external library
[Thread Prev] | [Thread Next]
- Subject: Re: Problem passing Array of Structs to external library
- From: Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
- Date: Thu, 4 Apr 2024 01:20:46 +0300
- To: user@xxxxxxxxxxxxxxxxxxxxxx
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] > ---- >
Attachment:
TestCommandical-0.0.29-FIXED.tar.gz
Description: application/gzip
Re: Problem passing Array of Structs to external library | Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> |
Re: Problem passing Array of Structs to external library | T Lee Davidson <t.lee.davidson@xxxxxxxxx> |
Problem passing Array of Structs to external library | T Lee Davidson <t.lee.davidson@xxxxxxxxx> |