Hi,

i've got a c declaration that i like to wrap:
    
    
            void crypto_ed25519_sign(u8        signature[64],
                                     const u8  secret_key[32],
                                     const u8 *message,
                                     size_t    message_size)
    

c2nim produces this:
    
    
    proc crypto_ed25519_sign*(signature: array[64, uint8]
                                     secret_key: array[32, uint8] message: ptr 
uint8
                                     message_size: csize)
    

to actually use it i had to change it like this:
    
    
    proc crypto_ed25519_sign*(signature: array[64, uint8];
                                     secret_key: array[32, uint8]; message: ptr 
openarray[uint8];
                                     message_size: csize) {.cdecl, importc: 
"crypto_ed25519_sign".}
    

the questions are:

  * what is the correct way to give arbitrary length data to message?
    (so what ist the eqvivalent to const u8 *message)
  * Atm i work around my limitation by declareing
    message: array[1024, uint8]

and give the actual msg size in message_size.

It seems system.nim declares a dummy 10_000 size array to avoid bound checks so 
i guess this is a somewhat convenient way of doing it?




greetings

Reply via email to