From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA05085; Mon, 27 Aug 2001 09:27:07 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA04963 for ; Mon, 27 Aug 2001 09:27:06 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f7R7R4P18934 for ; Mon, 27 Aug 2001 09:27:04 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.4/8.11.4) with UUCP id f7R7QpA14156 for caml-list@inria.fr; Mon, 27 Aug 2001 11:26:51 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from dialin1.stormoff (DIMA) [192.168.0.129] by stormoff with esmtp (Exim 2.05 #1 (Debian)) id 15bGh6-0002Rt-00; Mon, 27 Aug 2001 11:20:24 +0400 X-Comment-To: T Teemu E Kurppa To: caml-list@inria.fr Subject: Re: [Caml-list] CamlIDL: omitting struct fields References: From: Dmitry Bely Date: 27 Aug 2001 11:20:02 +0400 In-Reply-To: Message-ID: <1ylyj7fh.fsf@mail.ru> User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk T Teemu E Kurppa writes: > 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 > (http://caml.inria.fr/camlidl/htmlman/main006.html), 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 ? Maybe :-) If you really need the trick with fields omitting (BTW, why?), you should manually include the header file with "bar" definition into the camlidl-generated c_idl.c, so it will use the correct memory layout. Camlidl manual says that very clear. > - c_impl.c: --------------------------- > > #include > > 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); > return; > } > > > > - c_idl.idl: ------------------------------ > struct bar { > int x; > //int y; > int z; > }; > > void f ([in,ref] struct bar* pbar); > > > > - idl_test.ml: --------------------------- > open C_idl > > let main () = > let bar = {x = 1; > (*y = 2;*) > z = 3} in > f(bar) > > let _ = main () Hope to hear from you soon, Dmitry ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr