[Gambas-user] Arrays in Structures

Demosthenes Koptsis demosthenesk at gmail.com
Sun Jun 17 15:27:11 CEST 2018


Thanks Tobias!


On 06/17/2018 02:44 PM, Tobias Boege wrote:
> On Sun, 17 Jun 2018, Demosthenes Koptsis wrote:
>> Hello,
>>
>> may i have an example of an Array in a Struct ?
>>
>> *PUBLIC* *STRUCT* _Identifier_ ... _Field /k/_ [ _Embedded array
>> declaration_ ] *AS* [ _Datatype_ ] ... *END STRUCT*
>>
>>
>> is the next one correct?
>>
>> Public Struct aioinit
>>    aio_threads As Integer
>>    aio_num As Integer
>>    aio_locks As Integer
>>    aio_usedba As Integer
>>    aio_debug As Integer
>>    aio_numusers As Integer
>>    aio_reserved[2] As Integer[]
>> End Struct
>>
>> when i run it it does not complain for errors.
>>
> That of course depends on what you want to do. The above gives you
> an embedded array of size 2, whose elements are Integer[] objects.
>
> If you're interfacing with external libraries, you likely want
> it to be just two integers:
>
>    aio_reserved[2] As Integer
>
> Also note that my local manual tells me that one of the reserved
> ints became used "already" in glibc 2.2 (that was around the beginning
> of the millennium):
>
>      struct aioinit {
>        int aio_threads;    /* Maximum number of threads */
>        int aio_num;        /* Number of expected simultaneous
>                               requests */
>        int aio_locks;      /* Not used */
>        int aio_usedba;     /* Not used */
>        int aio_debug;      /* Not used */
>        int aio_numusers;   /* Not used */
>        int aio_idle_time;  /* Number of seconds before idle thread
>                               terminates (since glibc 2.2) */
>        int aio_reserved;
>    };
>
> Regards,
> Tobi
>



More information about the User mailing list