From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B6B87BC37 for ; Fri, 30 Oct 2009 10:35:03 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.44,652,1249250400"; d="scan'208";a="35864330" Received: from estephe.inria.fr ([128.93.11.95]) by mail2-relais-roc.national.inria.fr with ESMTP; 30 Oct 2009 10:35:03 +0100 Message-ID: <4AEAB347.3060008@inria.fr> Date: Fri, 30 Oct 2009 10:35:03 +0100 From: Xavier Leroy User-Agent: Thunderbird 2.0.0.17 (X11/20080929) MIME-Version: 1.0 To: Adrien Cc: Caml Mailing List Subject: Re: [Caml-list] Binding C libraries which use variable arguments (stdarg.h) References: <666572260910281507q74cb1c1at157c9e3c86070c69@mail.gmail.com> <4AE8C987.8020100@starynkevitch.net> <666572260910291418p585b0aa9laadc14f6589c9772@mail.gmail.com> In-Reply-To: <666572260910291418p585b0aa9laadc14f6589c9772@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 sizeof:01 bindings:01 synthesize:01 statically:01 invoke:01 caml-list:01 functions:01 portability:02 argument:02 binding:02 native:03 library:03 dynamic:03 86,:04 [Invoking a variadic C argument from OCaml] >> Assuming a Linux system, you could lazily generate the glue code and >> invoke dynamic linker on it. So the general case would be to call the >> code generator. > > On linux and x86, I could probably use an array where I would move by > sizeof(some_type). I really want portability however (I want to use > these bindings at least on windows too). It might be worth investigating the "libffi" library. If I guess correctly, it lets you synthesize calls to native C functions when the number and type of arguments are statically unknown. - Xavier Leroy