Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] CamlIDL: omitting struct fields
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: T Teemu E Kurppa <ttkurppa@c...>
Subject: [Caml-list] CamlIDL: omitting struct fields
Last weekend I started working on a hobby project, where I'll use Ocaml to
implement some parts of game AI for a game, which itself is written in
plain C. I'm using CamlIDL to help interfacing between C and Ocaml.

Unfortunately I encountered problems, when I omitted some struct fields
from IDL specification. According the chapter 6 of CamlIDL manual
(, omitting irrelevant
struct fields should be possible.

However, a following example doesn't work the way I think it should work.
In the C struct, three int fields x,y,z are defined. In IDL definition,
I omit y.

Program prints
x=1, y=3, z=134648512
althought I think it should print (of course y can be any number)
x=1, y=4911232, z=3

Have I misunderstood something ?

- c_impl.c: ---------------------------

#include <stdio.h>

struct bar {
  int x;
  int y;
  int z;

void f (struct bar* pbar) {
  printf ("x=%d, y=%d, z=%d\n", pbar->x, pbar->y, pbar->z);

- c_idl.idl: ------------------------------
struct bar {
  int x;
  //int y;
  int z;

void f ([in,ref] struct bar* pbar);

- ---------------------------
open C_idl

let main () =
  let bar = {x = 1;
           (*y = 2;*)
             z = 3} in

let _ = main ()

Teemu Kurppa

Bug reports:  FAQ:
To unsubscribe, mail  Archives: