I am new to Julia and trying to compile a function. My code is something like this and I get an error saying "@ccallable: argument types must be concrete" when I run the code. I also found this is because of the initial value I set to the function. Could anyone help me to solve this problem?
# this doesn't work
Base.@ccallable function test_function(a::Vector{Float64}, b::Float64, c=0.0::Float64)::Vector{Int64}
c = b + c
return a
end
# this works
Base.@ccallable function test_function(a::Vector{Float64}, b::Float64, c::Float64)::Vector{Int64}
c = b + c
return a
end
The function needs to be C-compatible and C does not have optional arguments.
Also, you probably don't want to take Julia Arrays from C, you want to take pointers, see the example at https://github.com/simonbyrne/libcg/blob/25e859ef587f3d00a0a8b6f304a7494f222874d3/CG/src/CG.jl#L27-L38.