File tree Expand file tree Collapse file tree 5 files changed +26
-7
lines changed Expand file tree Collapse file tree 5 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,20 @@ let rec core_type_from_ir typ =
32
32
| Ir. Prim Char -> Typ. constr (lid " char" ) []
33
33
| Ir. Prim Void -> Typ. constr (lid " unit" ) []
34
34
| Ir. Ptr t -> core_type_from_ir t
35
- | Ir. Func { fn_ret; fn_params } ->
36
- List. fold_left
37
- (fun acc (name , typ ) ->
38
- let label = Asttypes. Labelled name in
39
- let typ = core_type_from_ir typ in
40
- Typ. arrow label typ acc)
41
- (core_type_from_ir fn_ret) fn_params
35
+ | Ir. Func { fn_ret; fn_params } -> (
36
+ match fn_params with
37
+ | [] ->
38
+ (* If the C function declaration has no parameters we must introduce a `unit` param *)
39
+ Typ. arrow Asttypes. Nolabel
40
+ (core_type_from_ir (Ir. Prim Void ))
41
+ (core_type_from_ir fn_ret)
42
+ | params ->
43
+ List. fold_left
44
+ (fun acc (name , typ ) ->
45
+ let label = Asttypes. Labelled name in
46
+ let typ = core_type_from_ir typ in
47
+ Typ. arrow label typ acc)
48
+ (core_type_from_ir fn_ret) params)
42
49
43
50
let type_from_ir typ =
44
51
match typ with
Original file line number Diff line number Diff line change @@ -31,4 +31,10 @@ void caml_eleven_out_of_ten_majestic_af(value caml_pupper) {
31
31
CAMLreturn0 ;
32
32
}
33
33
34
+ void caml_no_input_no_output () {
35
+ CAMLparam0 ();
36
+ no_input_no_output ();
37
+ CAMLreturn0 ;
38
+ }
39
+
34
40
Original file line number Diff line number Diff line change @@ -13,3 +13,6 @@ void eleven_out_of_ten_majestic_af(Doggo* pupper) {
13
13
printf ("doggo is a %s\n" , BreedToString [pupper -> breed ]);
14
14
}
15
15
16
+ void no_input_no_output (void ) {
17
+ printf ("We are doing nothing (of importance)\n" );
18
+ }
Original file line number Diff line number Diff line change @@ -12,3 +12,5 @@ typedef struct Doggo {
12
12
} Doggo ;
13
13
14
14
void eleven_out_of_ten_majestic_af (Doggo * pupper );
15
+
16
+ void no_input_no_output (void );
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ type nonrec doggo = {
10
10
wow : char }
11
11
external eleven_out_of_ten_majestic_af :
12
12
pupper :doggo -> unit = " caml_eleven_out_of_ten_majestic_af"
13
+ external no_input_no_output : unit -> unit = " caml_no_input_no_output"
You can’t perform that action at this time.
0 commit comments