[Glass] Pass a const struct argument to a C function

Bruno Buzzi smalltalk at vera.com.uy
Mon Jul 27 12:08:39 PDT 2020


I think this problem has been fixed (more tests needed) but it seems that #'&ptr' must be defined in function 1) rather than function 2). 

After more testing i will confirm if it has been fixed. 


----- Mensaje original -----

De: "smalltalk--- via Glass" <glass at lists.gemtalksystems.com> 
Para: glass at lists.gemtalksystems.com 
Enviados: Lunes, 27 de Julio 2020 14:29:35 
Asunto: [Glass] Pass a const struct argument to a C function 

Implementing some FFI i reached the following situation: 

1) int ssh_pki_import_pubkey_file (const char * filename, ssh_key * pkey) | in GS #( #'const char*' #'ptr') 
This functions populate a ssh_key struct (a GS CPointer instance) and is working ok. 

Now i want to call the following function: 
2) int ssh_userauth_try_publickey (ssh_session session, const char * username, const ssh_key pubkey) | in GS #( #'ptr' #'const char*' #'ptr' ) 

The ssh_key struct is the same but with const instead of a *. 

If the result of 1) (aCPointer) is passed as received from FFI to function 2) --> function 2) fail. 
In this case at GS level the struct is #'ptr'. 

Then i tried to modify the FFI call with #'&ptr' to get the value of the pointer (so i can match const ssh_key) but it also fail. 

How i should update a CPointer of 1) instance to match const ssh_key of 2) ? (where ssh_key is a struct) 


Glass mailing list 
Glass at lists.gemtalksystems.com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gemtalksystems.com/mailman/private/glass/attachments/20200727/fcf47ea6/attachment.htm>

More information about the Glass mailing list