The manual’s “Calling C and Fortran Code > Indirect Calls” section provides the following macro to allow using a non-constant function spec with ccall
:
macro dlsym(func, lib)
z = Ref{Ptr{Cvoid}}(C_NULL)
quote
let zlocal = $z[]
if zlocal == C_NULL
zlocal = dlsym($(esc(lib))::Ptr{Cvoid}, $(esc(func)))::Ptr{Cvoid}
$z[] = $zlocal
end
zlocal
end
end
end
When I tried using it I got an error:
ERROR: LoadError: LoadError: LoadError: UndefVarError: zlocal not defined
I’m just getting started with Julia and have barely ventured into macros but I think the fix $z[] = zlocal
is needed. Is this just a typo in the manual?