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 GAA24561; Fri, 19 Jul 2002 06:45:19 +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 GAA24557 for ; Fri, 19 Jul 2002 06:45:18 +0200 (MET DST) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6J4jH125437 for ; Fri, 19 Jul 2002 06:45:17 +0200 (MET DST) Received: (from uucp@localhost) by relay.rinet.ru (8.11.6/8.11.6) with UUCP id g6J4jHX07404 for caml-list@inria.fr; Fri, 19 Jul 2002 08:45:17 +0400 (MSD) X-Envelope-To: caml-list@inria.fr Received: from dialin1.stormoff (ROVER1) [192.168.0.129] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 17VPXA-0004Go-00; Fri, 19 Jul 2002 08:38:34 +0400 X-Comment-To: Brian Naylor To: caml-list@inria.fr Subject: Re: [Caml-list] camlidl - character arrays? References: <20020719011110.49051.qmail@web13405.mail.yahoo.com> From: Dmitry Bely Date: Fri, 19 Jul 2002 08:38:20 +0400 In-Reply-To: <20020719011110.49051.qmail@web13405.mail.yahoo.com> (Brian Naylor's message of "Thu, 18 Jul 2002 18:11:10 -0700 (PDT)") Message-ID: <65zcgwn7.fsf@mail.ru> User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Common Lisp (Windows [3]), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Naylor 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