caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] camlidl - character arrays?
@ 2002-07-19  1:11 Brian Naylor
  2002-07-19  4:38 ` Dmitry Bely
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Naylor @ 2002-07-19  1:11 UTC (permalink / raw)
  To: caml-list

I am trying to use CamlIDL for a C function like the following:

    int foo (unsigned char [16]);

If I write my CamlIDL file like this:

    int foo ([in,string] unsigned char s [16]);

The code does a check like this:

    if (string_length(_v_s) >= 16) invalid argument("foo");

The problem is that this is NOT a null-terminated string - it is exactly 16
bytes of data.

Is there a way to write the CamlIDL file for this function?  Thanks.


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] camlidl - character arrays?
  2002-07-19  1:11 [Caml-list] camlidl - character arrays? Brian Naylor
@ 2002-07-19  4:38 ` Dmitry Bely
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Bely @ 2002-07-19  4:38 UTC (permalink / raw)
  To: caml-list

Brian Naylor <bwv211mail@yahoo.com> writes:

> I am trying to use CamlIDL for a C function like the following:
>
>     int foo (unsigned char [16]);
>
> If I write my CamlIDL file like this:
>
>     int foo ([in,string] unsigned char s [16]);
>
> The code does a check like this:
>
>     if (string_length(_v_s) >= 16) invalid argument("foo");
>
> The problem is that this is NOT a null-terminated string - it is exactly 16
> bytes of data.

You have two options here:

1. Don't use "string" attribute and pass OCaml character array (not string)
to your function or
2. Declare it as
     int foo ([string] unsigned char s[17]);
As C arrays are passed by the pointer, your C function will never know that
the trailing '\0' is there.

Dmitry Bely


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-07-19  4:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-19  1:11 [Caml-list] camlidl - character arrays? Brian Naylor
2002-07-19  4:38 ` Dmitry Bely

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).