ocaml - Using arrays with Ctypes -


i have quicksort function in c want bind ocaml using ctypes.

the declaration follows:

void quicksort(int array[], int first, int last) 

i don't know type put array in second parameter of foreign:

let cquicksort = foreign     "quicksort" (??? @-> int @-> int @-> returning void) ;; 

you can use void pointer in this tutorial.

let cquicksort = foreign     "quicksort" (ptr void @-> int @-> int @-> returning void)  let start = to_voidp (carray.start (carray.of_list int[1;2;3;4;3]));;  let () =      let carr = carray.of_list int [1;2;4;5;3] in         let start = to_voidp (carray.start carr) in             cquicksort start 0 4; 

after quicksort can use carray.to_list sorted list.


Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -