rexim 6 years ago
parent
commit
104353d6c0
6 changed files with 13 additions and 6 deletions
  1. 2 0
      ocaml-c/.gitignore
  2. 5 0
      ocaml-c/Makefile
  3. 0 1
      ocaml-c/funs.ml
  4. 0 1
      ocaml-c/funs.mli
  5. 4 0
      ocaml-c/hello.ml
  6. 2 4
      ocaml-c/hello_stubs.c

+ 2 - 0
ocaml-c/.gitignore

@@ -4,3 +4,5 @@
 *.so
 *.o
 *.a
+*.cmx
+hello.opt

+ 5 - 0
ocaml-c/Makefile

@@ -0,0 +1,5 @@
+hello: hello_stubs.c hello.ml
+	ocamlc -o hello.opt hello.ml hello_stubs.c
+
+hello.opt: hello_stubs.c hello.ml
+	ocamlopt -o hello.opt hello.ml hello_stubs.c

+ 0 - 1
ocaml-c/funs.ml

@@ -1 +0,0 @@
-external send_an_int: int -> unit = "get_an_int"

+ 0 - 1
ocaml-c/funs.mli

@@ -1 +0,0 @@
-external send_an_int : int -> unit = "get_an_int"

+ 4 - 0
ocaml-c/hello.ml

@@ -0,0 +1,4 @@
+external print_hello: unit -> unit = "caml_print_hello"
+
+let () =
+  print_hello ()

+ 2 - 4
ocaml-c/wrap.c → ocaml-c/hello_stubs.c

@@ -2,10 +2,8 @@
 #include <caml/mlvalues.h>
 
 CAMLprim value
-get_an_int( value v )
+caml_print_hello(value unit)
 {
-    int i;
-    i = Int_val(v);
-    printf("%d\n", i);
+    printf("Hello\n");
     return Val_unit;
 }