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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -