The ArchGDAL.jl package is apparently using this for the GDALProgressFunc
callback API.
It seems like the solution is to change the Julia package to use the void*
argument (pProgressArg
) to pass the closure argument, rather than forcing Julia to compile a new callback for every progressfunc
argument it wants to handle (which apparently isn’t supported on M1). That is, they should define something like:
function progressfunc_wrapper(dfComplete::Cdouble, pszMessage::Ptr{UInt8}, pProgressArg::Any)::Cint
pszMessage == C_NULL && return pProgressArg(dfComplete)
return pProgressArg(dfComplete, unsafe_string(pszMessage))
end
const progressfunc_wrapper_c = @cfunction(progressfunc_wrapper, Cint, (Cdouble, Cstring, Any))
and then, any place you actually want to pass a progressfunc
, you instead pass progressfunc_wrapper_c
as the callback function and progressfunc
as the callback-data argument.
In APIs that support a callback-data argument, like this one, the above is the approach I would recommend. It puts a lot fewer demands on the compiler.
(Also, then their progresscallback
functions are simpler and more Julian. They are passed a Julia String
as their optional “message” argument rather than a pointer, and can return true
or false
instead of a Cint
, since progressfunc_wrapper
handles the conversions.)