<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/00e8a9febc831f40f2e606996c6fb390"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-19T04:45:19"
  subject="Re: [Caml-list] camlidl - character arrays?"
  prev="2002/07/4ea471c9b5dc5d496a40fb34a60d9f00"
  next="2002/07/5fdf0ba8a79432a56fe1505fb0ba04f2"
  prev-in-thread="2002/07/1555d185cf3a3a8758041c92a7f7d521"
  prev-thread="2002/07/315f6c499a501e6f0b02d1bddacd4ee1"
  next-thread="2002/07/71c26b67baafe720885c555fc4a75f00"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] camlidl - character arrays?">
<msg 
  url="2002/07/1555d185cf3a3a8758041c92a7f7d521"
  from="Brian Naylor &lt;bwv211mail@y...&gt;"
  author="Brian Naylor"
  date="2002-07-19T01:11:13"
  subject="[Caml-list] camlidl - character arrays?">
<msg 
  url="2002/07/00e8a9febc831f40f2e606996c6fb390"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-19T04:45:19"
  subject="Re: [Caml-list] camlidl - character arrays?">
</msg>
</msg>
</thread>

<contents>
Brian Naylor &lt;bwv211mail@yahoo.com&gt; writes:

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

</contents>

</message>

