From: Dmitry Bely <dbely@mail.ru>
To: caml-list@inria.fr
Subject: Re: [Caml-list] CamlIDL: omitting struct fields
Date: 27 Aug 2001 11:20:02 +0400 [thread overview]
Message-ID: <1ylyj7fh.fsf@mail.ru> (raw)
In-Reply-To: <Pine.LNX.4.33.0108270928120.13703-100000@harvakari.cs.Helsinki.FI>
T Teemu E Kurppa <ttkurppa@cs.Helsinki.FI> 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 <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);
> 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
next prev parent reply other threads:[~2001-08-27 7:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-27 6:48 T Teemu E Kurppa
2001-08-27 7:20 ` Dmitry Bely [this message]
2001-08-27 10:49 ` T Teemu E Kurppa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ylyj7fh.fsf@mail.ru \
--to=dbely@mail.ru \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).