Hello All,

Here is some Julia code I've been fiddling with:

# c prototypes
#
#typedef int (*pq_service_handler)(int *exit_flag, void *user_data);

#int pq_service_create (const char *name, 
#                       const char *desc, 
#                       pq_service_handler init_func, 
#                       pq_service_handler service_func, 
#                       void *user_data);




function init_func{T}(a_::Ptr{T}, b_::Ptr{T})

  a = unsafe_load(a_)
  b = unsafe_load(b_)
  
  return convert(Cint, 0)

end

const init_func_c = cfunction(init_func, Cint, (Ptr{Cint}, Ptr{Void})) # [ 
line 9 ]



function service_func{T}(a_::Ptr{T}, b_::Ptr{T})

  a = unsafe_load(a_)
  b = unsafe_load(b_)

  while a == 0
    sleep(1)
  end  

  return convert(Cint, 0)

end

const service_func_c = cfunction(service_func, Cint, (Ptr{Cint}, Ptr{Void}))



ccall((:pq_service_create, 
"/build/compvia/x86_linux_64/pqvm/libservice.so"), 
      Int32, 
      (Ptr{Uint8}, Ptr{Uint8}, init_func_c, service_func_c, Ptr{Void}), 
      "test_service", "test_service", init_func, service_func, 0)


I keep getting the following error:

ERROR: function is not yet c-callable
 in cfunction at c.jl:23
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
while loading /build/compvia/src/pqvm/service_test.jl, in expression 
starting on line 9

Have I misunderstood something with regard to how this callback business 
works?

Thanks,
-G


Reply via email to