(edited, see next comment for the correct solution)
julia> function f end
begin
global f
f(x) = x * x
ptr = @cfunction(f, Cdouble, (Cdouble,))
g(x) = ccall(ptr, Cdouble, (Cdouble,), x)
g(1.2)
end
1.44