0

I am using libffi to call a function. but it is not invoking the same, Also i am not getting any errors. I am expecting a float value as return but it is returning as 0.0000. I am sure that it is not the return value expected(tried hardcoding).

if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI,
                2, &ffi_type_float, arg_types)) == FFI_OK)
        {
                ffi_call(&cif, my_function, result, arg_values);
        }

Am i doing anything wrong here? Is there any way to check ffi_call is success or not?

A R
  • 2,697
  • 3
  • 21
  • 38
  • have you put debugging msgs to 1. see the values for both function calls, 2. confirm you're entering the if block (or add an `else {printf "failed"}` 3. surround `ffi_call` with an `if, else` block. If so, please update your question to include that output. Good luck. – shellter Nov 12 '13 at 15:39
  • The problem may be in arg_types or in arg_values, it is difficult to say. in addition to the good suggestion of shellter you may want to have a look here http://koeritz.com/docs/libffi6/html/Simple-Example.html – Jekyll Nov 12 '13 at 16:26
  • What does ffi_prep_cif() return? Presumably it's not FFI_OK. – Anthony Green Jan 06 '14 at 16:48

0 Answers0