[squeak-dev] FFI (Plugin) | Question about multi-dimensional arrays (e.g., char**, int**, void*****...)

Tobias Pape Das.Linux at gmx.de
Mon Jun 15 13:00:50 UTC 2020


> On 15.06.2020, at 14:52, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
> 
> > Hello, C99:
> 
> So, "char (*libs[n])" would be equivalent to "char *libs[n]", which is an array of n pointers, each pointing to a character ... which is a null-terminated string, I suppose? Like "char **argv" or "char *argv[]" ... but with n

It is an array of n char-pointers (in fact, C-Strings), and n refers to an earlier variable in the parameter list...

BTW: "char *libs[n]" doesn't work and won't compile ;)
-t

> 
> Best,
> Marcel
>> Am 15.06.2020 14:34:02 schrieb Tobias Pape <das.linux at gmx.de>:
>> 
>> 
>> > On 15.06.2020, at 14:24, Jakob Reschke wrote:
>> > 
>> > 
>> > Marcel Taeumel schrieb am Mo., 15. Juni 2020, 13:22:
>> > 
>> > - Accept type names such as "int **" or "int[][]" in FFI-call specs and struct-field spec
>> > 
>> > One further note: int[][] is not valid C in parameter types. Only the first [] can be without length, and is equivalent to a pointer. So char*argv[] is the same as char**argv. Valid parameter type examples: int a[][3], int b[][2][3]. These are like int(*a)[3] and int(*b)[2][3] if I am not mistaken.
>> > 
>> 
>> Hello, C99:
>> 
>> /* Find all paths that may contain dynamic libraries.
>> * Returns their count. libs may be NULL to get allocation size
>> */
>> static size_t _sqo_lib_paths(size_t const n, char (*libs[n]))
>> {
>> /*...*/
>> }
>> 
>> ;)
>> 
>> -t
>> 
> 




More information about the Squeak-dev mailing list