[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Calling curl_easy_setopt crashes on 64-bit Debian stable



Tero Koskinen <tero.koskinen@iki.fi> writes:

>    procedure printf (S : Interfaces.C.char_array; I : Interfaces.C.Int);
>    pragma Import (C, printf, "printf");

This is _not_ guaranteed to work; see gnat user guide, 2.10.2 Calling
Conventions: 

     A note on interfacing to a C "varargs" function: 

        * In C, `varargs' allows a function to take a variable number of
          arguments. There is no direct equivalent in this to Ada. One
          approach that can be used is to create a C wrapper for each
          different profile and then interface to this C wrapper. For
          example, to print an `int' value using `printf', create a C
          function `printfi' that takes two arguments, a pointer to a
          string and an int, and calls `printf'.  Then in the Ada
          program, use pragma `Import' to interface to `printfi'.

        * It may work on some platforms to directly interface to a
          `varargs' function by providing a specific Ada profile for a
          particular call. However, this does not work on all
          platforms, since there is no guarantee that the calling
          sequence for a two argument normal C function is the same as
          for calling a `varargs' C function with the same two
          arguments.

-- 
-- Stephe


Reply to: