<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi all,</div><div><br></div><div>I have a problem with FFI which is certainly due to my lack of experience with c, and would very much appreciate any help.</div><div>I am using&nbsp;(_list i _string) to pass an array of strings to a c function, but all that ends up on the other side seems to be "nonsense" / random characters.</div><div><br></div><div>The c function is described as</div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><b><br></b></span></font></div><div><b><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">boolean OCI_BindArrayOfStrings</span></font><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">(OCI_Statement * stmt, const mtext * name, dtext * data, unsigned int len, unsigned int nbelem)</span></font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">        </span></font></span></b></div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><b><br></b></span></font></div><div>where mtext and dtext are aliases for char, the way the library was compiled, the second-but-last argument has to indicate the length of the longest string in the array, and the last argument has to be 0 apart from a special case not applicable here.</div><div>I've defined it as</div><div><br></div><div><div>(def-ocilib bindstringarray OCI_BindArrayOfStrings : (stmt_ptr : _pointer) (name : _string) (data : (_list i _string)) (maxstrlen : _uint = (getmaxlength data)) (no : _uint) -&gt; (result : _bool))</div></div><div><br></div><div>where maxstrlen gives the length of the longest list member.</div><div>The function does not give any error, only the transmitted strings are random/whatever.</div><div><br></div><div><br></div><div>I have a "parallel" function using (_list i _int) to pass an array of ints, and this one works fine. Second,&nbsp;&nbsp;I have no problem passing a single input string, as in</div><div><br></div><div>(def-ocilib bindstring OCI_BindString : (stmt_ptr : _pointer) (name : _string) (data : _string) (len : _int = (string-length data)) -&gt; (result : _bool))</div><div><br></div><div>so I think I am using the _list construct itself correctly, and the datatype _string itself works fine, too - but there might be special things to pay attention to when passing arrays of strings, perhaps somehow related to field delimitation...?</div><div><br></div><div><br></div><div>By the way, I also have another problem understanding the (varname : (_list mode type)) form. If the varname still refers to the racket side, I should be able to pass it to a racket function, as I do with the</div><div>(data : (_list i _string))</div><div>in the "misbehaving" function cited above, doing&nbsp;(getmaxlength data),&nbsp;&nbsp;and it works fine. But I also tried using</div><div>(data : &nbsp;(_list io _string (length data))&nbsp;</div><div>instead, in order to check the correctness of the input strings, putting them out as part of the functions return values, but for doing (length data) I get the error</div><div><br></div><div>length: expects argument of type &lt;proper list&gt;; given #&lt;cpointer&gt;</div><div><br></div><div>so here data seems to be a c type, not a racket list anymore...</div><div><br></div><div>Many thanks in advance for any help regarding the above problem, and understanding the latter point :-)</div><div><br></div><div>Ciao,</div><div>Sigrid</div></body></html>