Hi all,
I’m writing my first non-trivial Julia project. I’ve run into a problem I can’t quite figure out. I want to use quaternions from the Quaternion package and send them to a C library that takes quaternions as a four element Float32 array. So I’ve written the following convert routine:
unsafe_convert(::Type{Ptr{Float32}}, q::Quaternions.Quaternion{Float64}) =
convert(Ptr{Float32}, Ptr{Float32}(pointer_from_objref([imag(q), real(q)])))
which is declared inside the module that needs it. This code works fine from the REPL, I get the following:
julia> q = Quaternion(1.0, 0.0, 0.0, 0.0)
1.0 + 0.0im + 0.0jm + 0.0km
julia> x = Ptr{Float32}
Ptr{Float32}
julia> unsafe_convert(x, q)
Ptr{Float32} @0x0000000113d2a890
But when I put it in the module and try to use I get the following:
julia> include("distance_example.jl")
WARNING: replacing module Distance
ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{Float32}}, ::Quaternions.Quaternion{Float64})
Closest candidates are: