From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,235855e3822c83d1,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.168 with SMTP id kj8mr10063028pbc.1.1334049719396; Tue, 10 Apr 2012 02:21:59 -0700 (PDT) Path: r9ni39726pbh.0!nntp.google.com!news1.google.com!postnews.google.com!z38g2000vbu.googlegroups.com!not-for-mail From: Maxim Reznik Newsgroups: comp.lang.ada Subject: Importing C function with variable argument list Date: Tue, 10 Apr 2012 02:21:59 -0700 (PDT) Organization: http://groups.google.com Message-ID: <610ee323-4c7f-413d-8568-aed4955f5152@z38g2000vbu.googlegroups.com> NNTP-Posting-Host: 93.127.37.234 Mime-Version: 1.0 X-Trace: posting.google.com 1334049719 17103 127.0.0.1 (10 Apr 2012 09:21:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 10 Apr 2012 09:21:59 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z38g2000vbu.googlegroups.com; posting-host=93.127.37.234; posting-account=K1cP1QoAAAD_GR6kW2Td0NqGqGBLRE8h User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-04-10T02:21:59-07:00 List-Id: Hi, All It seems it's impossible to call C function variable argument lists from Ada. Even when one knows in advace all arguments at compile time. Functions with Variable Argument Lists have their own ABI. For instance, in x86_64: > When a function taking variable-arguments is called, %rax must be set to the > total number of floating point parameters passed to the function in vector registers. But it's impossible to specify this fact in pragma Import (C, ... Small example: C declaration: void syslog (int __pri, __const char *__fmt, ...); Supposed Import declaration: procedure C_Syslog (Priority : int; Format : chars_ptr; Msg : chars_ptr); pragma Import (C, C_Syslog, "syslog"); Call to C_Syslog fails, because %rax has not zero value. What do you think?