I can't believe it was that simple. Thank you so much!
On Monday, July 28, 2014 10:16:21 PM UTC-7, Ivar Nesje wrote: > > It seems to me like the error is that you don't have a Julia method > results = gillespie (rr, 0) > that takes an Int as the second argument. the method you define only takes > a Float64, so you should probably call it with a Float64 as well. > results = gillespie (rr, 0.) > > Also I would think that RRHandle would be pointer sized, so you should > use Ptr{Void} instead of Uint for its type. > > Regards Ivar > > kl. 03:24:36 UTC+2 tirsdag 29. juli 2014 skrev Alexander Darling følgende: >> >> Hello, >> >> I am in the process of making Julia functions that use functions in >> C-exported libraries using "ccall". One of the functions I am writing >> throws errors when I try to include a double in the call. I think this is >> because I'm using the wrong type instead of double (Float64) but I don't >> know what the correct type is and I'm not 100% sure that's the problem. >> >> This is the function in C: >> C_DECL_SPEC RRDataHandle rrcCallConv gillespie(RRHandle handle, double >> startTime) { >> // Things happen here >> return (RRDataHandle) r->getSimulationResult(); >> } >> >> >> Here is my test code. >> rrlib = dlopen("...\\roadrunner_c_api.dll") // the library that the >> "gillespie" function is from >> >> function gillespie(rr, startTime::Float64) >> return ccall (dlsym (rrlib,:gillespie),cdecl, Uint,(Uint, Float64),rr, >> startTime) >> end >> >> //The object "rr" is set up here >> results = gillespie (rr, 0) >> >> And this is the error that gets thrown. For context, The "gillespie" >> function is called on line 106 and the "rr" object's memory address is >> @0x23dc4c08.: >> LoadError(".../myTest.jl", 106, MethodError(gillespie, (Ptr{Void} @ >> 0x23dc4c08,0))) >> >> When I modify the function in C and the middleman function in Julia so >> that both only takes the "rr" argument and not "startTime", it works fine. >> In addition, the function works just fine in C with two arguments. I >> suspect it's because the "startTime" in Julia is a Float64, and C requires >> a double. However changing the "startTime" argument in the C function into >> a float just gives me the same error. >> >