On Wed, Nov 18, 2015 at 4:31 PM, Martin Kuzma <martin.kuzm...@gmail.com> wrote:
> Hello, I am learning Julia and reading the documentation.
> There is this example:
>
> function gethostname()
>   hostname = Array(UInt8, 128)
>   ccall( (:gethostname, "libc"), Int32,
>         (Ptr{UInt8}, UInt),
>         hostname, length(hostname))
>   return bytestring(convert(Ptr{UInt8}, hostname))
> end
>
> I get the following error when calling the function:
>
> ERROR: MethodError: `convert` has no method matching
> convert(::Type{Ptr{UInt8}}, ::Array{UInt8,1})
> This may have arisen from a call to the constructor Ptr{UInt8}(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert{T}(::Type{Ptr{T}}, ::UInt64)
>   convert{T}(::Type{Ptr{T}}, ::Int64)
>   ...
>  in eval at ./boot.jl:263
>
>
> I am using julia Version 0.5.0-dev+1317. Anybody knows how to solve this
> problem? Thanks Martin

Look at the latest doc instead of the 0.3 one
http://julia.readthedocs.org/en/latest/manual/calling-c-and-fortran-code/#calling-c-and-fortran-code

Reply via email to